File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed
basex-core/src/main/java/org/basex/gui/view/editor Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff 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 /**
You can’t perform that action at this time.
0 commit comments