From a23a123aa02b021abdc87f8fc4a75064312e5f17 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Fri, 15 May 2020 16:28:30 +0200 Subject: [PATCH] sort references by full uri, group by uri without fragment, https://github.com/microsoft/vscode/issues/97881 --- package.json | 2 +- src/models.ts | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 2372ce1..c81111f 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/models.ts b/src/models.ts index e2410a8..a7fe2ea 100644 --- a/src/models.ts +++ b/src/models.ts @@ -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(source, uri, position)).then(loc => { - return loc?.sort(ReferencesModel._compareLocations) ?? []; - }); + const locations = Promise.resolve(vscode.commands.executeCommand(source, uri, position)).then(loc => loc ?? []); return new ReferencesModel(source, uri, position, locations); } @@ -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;