From 8ac832769abbd309c51b785d90c9c3d4c6d0035c Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 15 Dec 2015 11:35:30 +0100 Subject: [PATCH] Use same highlighting strategy for fuzzy and full path search (fixes #1293, fixes #1294) --- .../parts/quickopen/browser/quickOpenModel.ts | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/vs/base/parts/quickopen/browser/quickOpenModel.ts b/src/vs/base/parts/quickopen/browser/quickOpenModel.ts index 60061ddee35..aba77e6ef92 100644 --- a/src/vs/base/parts/quickopen/browser/quickOpenModel.ts +++ b/src/vs/base/parts/quickopen/browser/quickOpenModel.ts @@ -188,16 +188,16 @@ export class QuickOpenEntry { // Highlight file aware if (entry.getResource()) { - // Fuzzy: Highlight is special - if (fuzzyHighlight) { - let candidateLabelHighlights = Filters.matchesFuzzy(lookFor, entry.getLabel(), true); + // Fuzzy/Full-Path: Highlight is special + if (fuzzyHighlight || lookFor.indexOf(Paths.nativeSep) >= 0) { + let candidateLabelHighlights = Filters.matchesFuzzy(lookFor, entry.getLabel(), fuzzyHighlight); if (!candidateLabelHighlights) { const pathPrefix = entry.getDescription() ? (entry.getDescription() + Paths.nativeSep) : ''; const pathPrefixLength = pathPrefix.length; // If there are no highlights in the label, build a path out of description and highlight and match on both, // then extract the individual label and description highlights back to the original positions - let pathHighlights = Filters.matchesFuzzy(lookFor, pathPrefix + entry.getLabel(), true); + let pathHighlights = Filters.matchesFuzzy(lookFor, pathPrefix + entry.getLabel(), fuzzyHighlight); if (pathHighlights) { pathHighlights.forEach(h => { @@ -223,17 +223,6 @@ export class QuickOpenEntry { } } - // Path search: Highlight in label and description - else if (lookFor.indexOf(Paths.nativeSep) >= 0) { - descriptionHighlights = Filters.matchesFuzzy(Strings.trim(lookFor, Paths.nativeSep), entry.getDescription()); - - // If we have no highlights, assume that the match is split among name and parent folder - if (!descriptionHighlights || !descriptionHighlights.length) { - labelHighlights = Filters.matchesFuzzy(Paths.basename(lookFor), entry.getLabel()); - descriptionHighlights = Filters.matchesFuzzy(Strings.trim(Paths.dirname(lookFor), Paths.nativeSep), entry.getDescription()); - } - } - // Highlight only inside label else { labelHighlights = Filters.matchesFuzzy(lookFor, entry.getLabel()); -- GitLab