Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5244daa

Browse files
committedNov 7, 2016
Use the same Comparator to sort EditorTab and SketchFile
1 parent c35469e commit 5244daa

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed
 

‎app/src/processing/app/Editor.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,22 +1691,11 @@ public void createTabs() {
16911691
selectTab(0);
16921692
}
16931693

1694-
private static final Comparator<EditorTab> CODE_DOCS_COMPARATOR = new Comparator<EditorTab>() {
1695-
@Override
1696-
public int compare(EditorTab x, EditorTab y) {
1697-
if (x.getSketchFile().isPrimary() && !y.getSketchFile().isPrimary())
1698-
return -1;
1699-
if (y.getSketchFile().isPrimary() && !x.getSketchFile().isPrimary())
1700-
return 1;
1701-
return x.getSketchFile().getFileName().compareTo(y.getSketchFile().getFileName());
1702-
}
1703-
};
1704-
17051694
/**
17061695
* Reorders tabs as per current sketch's files order
17071696
*/
17081697
public void reorderTabs() {
1709-
Collections.sort(tabs, CODE_DOCS_COMPARATOR);
1698+
Collections.sort(tabs, (x, y) -> Sketch.CODE_DOCS_COMPARATOR.compare(x.getSketchFile(), y.getSketchFile()));
17101699
}
17111700

17121701
/**

‎arduino-core/src/processing/app/Sketch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class Sketch {
3131

3232
private File buildPath;
3333

34-
private static final Comparator<SketchFile> CODE_DOCS_COMPARATOR = new Comparator<SketchFile>() {
34+
public static final Comparator<SketchFile> CODE_DOCS_COMPARATOR = new Comparator<SketchFile>() {
3535
@Override
3636
public int compare(SketchFile x, SketchFile y) {
3737
if (x.isPrimary() && !y.isPrimary())

0 commit comments

Comments
 (0)
Please sign in to comment.