Skip to content

Commit 80a873c

Browse files
[FIX] GUI, editor: opening new tabs
1 parent 07088cf commit 80a873c

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

basex-core/src/main/java/org/basex/gui/view/editor/EditorView.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,23 +1000,18 @@ private EditorArea find(final IO file) {
10001000
}
10011001

10021002
/**
1003-
* Choose a unique tab file.
1003+
* Choose a unique dummy file reference for a new tab.
10041004
* @return io reference
10051005
*/
10061006
private IOFile newTabFile() {
1007-
// collect numbers of existing files
1008-
final BoolList bl = new BoolList();
1007+
int n = 0;
10091008
for(final EditorArea edit : editors()) {
1010-
if(edit.opened()) continue;
1011-
final String n = edit.file().name().substring(FILE.length());
1012-
bl.set(n.isEmpty() ? 1 : Strings.toInt(n), true);
1009+
final String name = edit.file().name(), num = name.replaceAll("^" + FILE + "(\\d*)$", "$1");
1010+
if(!edit.opened() && !name.equals(num)) {
1011+
n = Math.max(n, num.isEmpty() ? 1 : Strings.toInt(num));
1012+
}
10131013
}
1014-
// find first free file number
1015-
int b = 0;
1016-
final int bs = bl.size();
1017-
while(++b < bs && bl.get(b));
1018-
// create io reference
1019-
return new IOFile(gui.gopts.get(GUIOptions.WORKPATH), FILE + (b == 1 ? "" : b));
1014+
return new IOFile(gui.gopts.get(GUIOptions.WORKPATH), FILE + (n == 0 ? "" : n + 1));
10201015
}
10211016

10221017
/**

0 commit comments

Comments
 (0)