!82 修复 BUG 重命名标签页改为相同名称标签页卡死问题

Merge pull request !82 from 格物方能致知/fix-I7ZWAW
This commit is contained in:
Luke 2023-09-09 02:39:58 +00:00 committed by Gitee
commit 7afdeeaf5d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -54,7 +54,8 @@ public class RenameFile implements EventHandler<ActionEvent> {
private void handleRenameTab(CenterTab centerTab) { private void handleRenameTab(CenterTab centerTab) {
TextField textField = new TextField(centerTab.getText()); TextField textField = new TextField(centerTab.getText());
textField.getStyleClass().add("tab-title-editable"); textField.getStyleClass().add("tab-title-editable");
// 临时记录标签页名称
String tempName = centerTab.getText();
// 清空标签页名称 // 清空标签页名称
centerTab.setText(""); centerTab.setText("");
@ -69,7 +70,7 @@ public class RenameFile implements EventHandler<ActionEvent> {
showDuplicateNameAlert(newTabName); showDuplicateNameAlert(newTabName);
// 恢复原始名称 // 恢复原始名称
centerTab.setText(centerTab.getUserData().toString()); centerTab.setText(tempName);
} else { } else {
centerTab.setText(newTabName); centerTab.setText(newTabName);
@ -87,7 +88,7 @@ public class RenameFile implements EventHandler<ActionEvent> {
// 检查是否存在相同名称的标签页 // 检查是否存在相同名称的标签页
if (isTabNameExists(newTabName)) { if (isTabNameExists(newTabName)) {
// 恢复原始名称 // 恢复原始名称
centerTab.setText(centerTab.getUserData().toString()); centerTab.setText(tempName);
} }
if (Boolean.FALSE.equals(newValue)) { if (Boolean.FALSE.equals(newValue)) {