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

This commit is contained in:
gewuyou 2023-09-09 10:20:46 +08:00
parent a619406005
commit 12b3959d5a

View File

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