Skip to content

Commit 2339049

Browse files
author
Federico Fissore
committed
When switching between tabs, add the name of the current file/tab to the title. Fixes #2765
1 parent df66775 commit 2339049

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

app/src/processing/app/Editor.java

+15-3
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,7 @@ protected void setCode(final SketchCodeDocument codeDoc) {
17711771
textarea.requestFocus(); // get the caret blinking
17721772

17731773
final int position = codeDoc.getScrollPosition();
1774-
1774+
17751775
// invokeLater: Expect the document to be rendered correctly to set the new position
17761776
SwingUtilities.invokeLater(new Runnable() {
17771777
@Override
@@ -1781,7 +1781,8 @@ public void run() {
17811781
redoAction.updateRedoState();
17821782
}
17831783
});
1784-
1784+
1785+
updateTitle();
17851786
}
17861787

17871788

@@ -2191,7 +2192,7 @@ protected boolean handleOpenInternal(File sketchFile) {
21912192
return false;
21922193
}
21932194
header.rebuild();
2194-
setTitle(I18n.format(_("{0} | Arduino {1}"), sketch.getName(), BaseNoGui.VERSION_NAME_LONG));
2195+
updateTitle();
21952196
// Disable untitled setting from previous document, if any
21962197
untitled = false;
21972198

@@ -2205,6 +2206,17 @@ protected boolean handleOpenInternal(File sketchFile) {
22052206
// }
22062207
}
22072208

2209+
private void updateTitle() {
2210+
if (sketch == null) {
2211+
return;
2212+
}
2213+
if (sketch.getName().equals(sketch.getCurrentCode().getPrettyName())) {
2214+
setTitle(I18n.format(_("{0} | Arduino {1}"), sketch.getName(), BaseNoGui.VERSION_NAME_LONG));
2215+
} else {
2216+
setTitle(I18n.format(_("{0} - {1} | Arduino {2}"), sketch.getName(), sketch.getCurrentCode().getFileName(), BaseNoGui.VERSION_NAME_LONG));
2217+
}
2218+
}
2219+
22082220

22092221
/**
22102222
* Actually handle the save command. If 'immediately' is set to false,

0 commit comments

Comments
 (0)