Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
sort references by full uri, group by uri without fragment, microsoft…
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed May 15, 2020
1 parent 8463674 commit a23a123
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Reference Search View",
"icon": "media/icon.png",
"description": "Reference Search results as separate, stable view in the sidebar",
"version": "0.0.55",
"version": "0.0.56",
"publisher": "ms-vscode",
"engines": {
"vscode": "^1.40.0"
Expand Down
14 changes: 6 additions & 8 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@ export class ReferenceItem {
export class ReferencesModel {

static create(uri: vscode.Uri, position: vscode.Position, source: ItemSource): ReferencesModel {
const locations = Promise.resolve(vscode.commands.executeCommand<vscode.Location[]>(source, uri, position)).then(loc => {
return loc?.sort(ReferencesModel._compareLocations) ?? [];
});
const locations = Promise.resolve(vscode.commands.executeCommand<vscode.Location[]>(source, uri, position)).then(loc => loc ?? []);
return new ReferencesModel(source, uri, position, locations);
}

Expand Down Expand Up @@ -276,11 +274,11 @@ export class ReferencesModel {
}

private static _compareLocations(a: vscode.Location, b: vscode.Location): number {
let ret = ReferencesModel._compareUriIgnoreFragment(a.uri, b.uri);
if (ret !== 0) {
return ret;
}
if (a.range.start.isBefore(b.range.start)) {
if (a.uri.toString() < b.uri.toString()) {
return -1;
} else if (a.uri.toString() < b.uri.toString()) {
return 1;
} else if (a.range.start.isBefore(b.range.start)) {
return -1;
} else if (a.range.start.isAfter(b.range.start)) {
return 1;
Expand Down

0 comments on commit a23a123

Please sign in to comment.