From de8f28930801ed7a864b41fe6956fa32bcc233a7 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 7 Dec 2015 10:50:40 +0100 Subject: [PATCH] Do not let highlights decide on visiblity in result set --- .../browser/parts/quickopen/editorHistoryModel.ts | 15 +++------------ .../parts/search/browser/openAnythingHandler.ts | 7 +++---- .../parts/search/browser/openFileHandler.ts | 2 ++ 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/vs/workbench/browser/parts/quickopen/editorHistoryModel.ts b/src/vs/workbench/browser/parts/quickopen/editorHistoryModel.ts index 36e1dc4e12f23..bc8297a6a0c34 100644 --- a/src/vs/workbench/browser/parts/quickopen/editorHistoryModel.ts +++ b/src/vs/workbench/browser/parts/quickopen/editorHistoryModel.ts @@ -227,19 +227,10 @@ export class EditorHistoryModel extends QuickOpenModel { // Apply highlights const {labelHighlights, descriptionHighlights} = QuickOpenEntry.highlight(entry, searchValue); - if ((labelHighlights && labelHighlights.length) || (descriptionHighlights && descriptionHighlights.length)) { - results.push(entry.clone(labelHighlights, descriptionHighlights)); - } - } - - // If user is searching, use the same sorting that is used for other quick open handlers - if (searchValue) { - let normalizedSearchValue = strings.stripWildcards(searchValue.toLowerCase()); - - return results.sort((elementA: EditorHistoryEntry, elementB: EditorHistoryEntry) => QuickOpenEntry.compare(elementA, elementB, normalizedSearchValue)); + results.push(entry.clone(labelHighlights, descriptionHighlights)); } - // Leave default "most recently used" order if user is not actually searching - return results; + // Sort + return results.sort((elementA: EditorHistoryEntry, elementB: EditorHistoryEntry) => QuickOpenEntry.compare(elementA, elementB, strings.stripWildcards(searchValue.toLowerCase()))); } } diff --git a/src/vs/workbench/parts/search/browser/openAnythingHandler.ts b/src/vs/workbench/parts/search/browser/openAnythingHandler.ts index 3ca4a408ef324..49a52235fca3e 100644 --- a/src/vs/workbench/parts/search/browser/openAnythingHandler.ts +++ b/src/vs/workbench/parts/search/browser/openAnythingHandler.ts @@ -252,10 +252,9 @@ export class OpenAnythingHandler extends QuickOpenHandler { // Apply highlights const {labelHighlights, descriptionHighlights} = QuickOpenEntry.highlight(entry, searchValue); - if ((labelHighlights && labelHighlights.length) || (descriptionHighlights && descriptionHighlights.length)) { - entry.setHighlights(labelHighlights, descriptionHighlights); - results.push(entry); - } + entry.setHighlights(labelHighlights, descriptionHighlights); + + results.push(entry); } // Sort diff --git a/src/vs/workbench/parts/search/browser/openFileHandler.ts b/src/vs/workbench/parts/search/browser/openFileHandler.ts index 5cdf6f7cb8f7c..294b4bffc5ce1 100644 --- a/src/vs/workbench/parts/search/browser/openFileHandler.ts +++ b/src/vs/workbench/parts/search/browser/openFileHandler.ts @@ -147,6 +147,8 @@ export class OpenFileHandler extends QuickOpenHandler { let description = labels.getPathLabel(paths.dirname(fileMatch.resource.fsPath), this.contextService); let entry = this.instantiationService.createInstance(FileEntry, label, description, fileMatch.resource); + + // Apply highlights let {labelHighlights, descriptionHighlights} = QuickOpenEntry.highlight(entry, searchValue); entry.setHighlights(labelHighlights, descriptionHighlights);