Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2018-06-25 09:04:53 -0400
committerThomas Wolf2018-06-25 09:43:02 -0400
commitf2790c82b8ad8dde9e8c96502448c29febd2b911 (patch)
tree4aaa9d2d79c32963ba2feea4cc7cd5cc1b36e3bd /org.eclipse.egit.ui/src/org/eclipse/egit/ui
parent95c6ac4e487b44bbffbc7f3ede071f78b9530ac1 (diff)
downloadegit-f2790c82b8ad8dde9e8c96502448c29febd2b911.tar.gz
egit-f2790c82b8ad8dde9e8c96502448c29febd2b911.tar.xz
egit-f2790c82b8ad8dde9e8c96502448c29febd2b911.zip
Fix sort order in Staging view
Change alphabetic sorting such that elements with shorter directory names in the path sort before elements with longer directory names. * Replace slashes by '\001' to ensure the above. * If "file name first" is active, sort by file name _and_ path to ensure relative order of files with the same name in different directories. * Also sort StagingFolderEntries the same way to ensure that the order is the same when "compact tree" representation is active. Also apply the same technique in FileDiff.PATH_COMPARATOR to ensure that we use a consistent ordering also in the history page and in the commit viewer and its outline page. Bug: 536240 Change-Id: I6a8daf7faed8a89a5b97f083e108cd614ba15096 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java7
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java11
2 files changed, 12 insertions, 6 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java
index b21f4b6b4..4a1830d48 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/FileDiff.java
@@ -70,12 +70,13 @@ public class FileDiff extends WorkbenchAdapter {
String rightPath = right.getPath();
int i = leftPath.lastIndexOf('/');
int j = rightPath.lastIndexOf('/');
- int p = leftPath.substring(0, i + 1)
- .compareTo(rightPath.substring(0, j + 1));
+ int p = leftPath.substring(0, i + 1).replace('/', '\001').compareTo(
+ rightPath.substring(0, j + 1).replace('/', '\001'));
if (p != 0) {
return p;
}
- return leftPath.compareTo(rightPath);
+ return leftPath.substring(i + 1)
+ .compareTo(rightPath.substring(j + 1));
}
};
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
index b76f0b478..6395190e7 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
@@ -4416,12 +4416,17 @@ public class StagingView extends ViewPart
private String getStagingEntryText(Object element) {
String text = ""; //$NON-NLS-1$
StagingEntry stagingEntry = getStagingEntry(element);
+ // Replace slashes by ASCII \001 to make e.g.
+ // "org.eclipse.egit.gitflow/..." sort before
+ // "org.eclipse.egit.gitflow.ui/...".
if (stagingEntry != null) {
+ text = stagingEntry.getPath().replace('/', '\001');
if (isFileNamesFirst()) {
- text = stagingEntry.getName();
- } else {
- text = stagingEntry.getPath();
+ text = stagingEntry.getName() + '\001' + text;
}
+ } else if (element instanceof StagingFolderEntry) {
+ text = ((StagingFolderEntry) element).getNodePath().toString()
+ .replace('/', '\001');
}
return text;
}

Back to the top