mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-01 12:24:14 +01:00
Use the same Comparator to sort EditorTab and SketchFile
This commit is contained in:
parent
c35469ea81
commit
5244daa5d1
@ -1691,22 +1691,11 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
selectTab(0);
|
||||
}
|
||||
|
||||
private static final Comparator<EditorTab> CODE_DOCS_COMPARATOR = new Comparator<EditorTab>() {
|
||||
@Override
|
||||
public int compare(EditorTab x, EditorTab y) {
|
||||
if (x.getSketchFile().isPrimary() && !y.getSketchFile().isPrimary())
|
||||
return -1;
|
||||
if (y.getSketchFile().isPrimary() && !x.getSketchFile().isPrimary())
|
||||
return 1;
|
||||
return x.getSketchFile().getFileName().compareTo(y.getSketchFile().getFileName());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Reorders tabs as per current sketch's files order
|
||||
*/
|
||||
public void reorderTabs() {
|
||||
Collections.sort(tabs, CODE_DOCS_COMPARATOR);
|
||||
Collections.sort(tabs, (x, y) -> Sketch.CODE_DOCS_COMPARATOR.compare(x.getSketchFile(), y.getSketchFile()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ public class Sketch {
|
||||
|
||||
private File buildPath;
|
||||
|
||||
private static final Comparator<SketchFile> CODE_DOCS_COMPARATOR = new Comparator<SketchFile>() {
|
||||
public static final Comparator<SketchFile> CODE_DOCS_COMPARATOR = new Comparator<SketchFile>() {
|
||||
@Override
|
||||
public int compare(SketchFile x, SketchFile y) {
|
||||
if (x.isPrimary() && !y.isPrimary())
|
||||
|
Loading…
Reference in New Issue
Block a user