Skip to content

Commit 6ff764c

Browse files
authored
Merge pull request microsoft#154499 from microsoft/tyriar/154497
Including whitespace in query for contiguous search
2 parents b39a312 + 96f310e commit 6ff764c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/vs/base/parts/quickinput/browser/quickInputList.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ export class QuickInputList {
612612
this.list.layout();
613613
return false;
614614
}
615+
616+
const queryWithWhitespace = query;
615617
query = query.trim();
616618

617619
// Reset filtering
@@ -634,7 +636,7 @@ export class QuickInputList {
634636
if (this.matchOnLabelMode === 'fuzzy') {
635637
labelHighlights = this.matchOnLabel ? withNullAsUndefined(matchesFuzzyIconAware(query, parseLabelWithIcons(element.saneLabel))) : undefined;
636638
} else {
637-
labelHighlights = this.matchOnLabel ? withNullAsUndefined(matchesContiguousIconAware(query, parseLabelWithIcons(element.saneLabel))) : undefined;
639+
labelHighlights = this.matchOnLabel ? withNullAsUndefined(matchesContiguousIconAware(queryWithWhitespace, parseLabelWithIcons(element.saneLabel))) : undefined;
638640
}
639641
const descriptionHighlights = this.matchOnDescription ? withNullAsUndefined(matchesFuzzyIconAware(query, parseLabelWithIcons(element.saneDescription || ''))) : undefined;
640642
const detailHighlights = this.matchOnDetail ? withNullAsUndefined(matchesFuzzyIconAware(query, parseLabelWithIcons(element.saneDetail || ''))) : undefined;
@@ -733,13 +735,13 @@ export class QuickInputList {
733735
}
734736
}
735737

736-
export function matchesContiguousIconAware(query: string, target: IParsedLabelWithIcons, enableSeparateSubstringMatching = false): IMatch[] | null {
738+
export function matchesContiguousIconAware(query: string, target: IParsedLabelWithIcons): IMatch[] | null {
737739

738740
const { text, iconOffsets } = target;
739741

740742
// Return early if there are no icon markers in the word to match against
741743
if (!iconOffsets || iconOffsets.length === 0) {
742-
return matchesContiguous(query, text, enableSeparateSubstringMatching);
744+
return matchesContiguous(query, text);
743745
}
744746

745747
// Trim the word to match against because it could have leading
@@ -748,7 +750,7 @@ export function matchesContiguousIconAware(query: string, target: IParsedLabelWi
748750
const leadingWhitespaceOffset = text.length - wordToMatchAgainstWithoutIconsTrimmed.length;
749751

750752
// match on value without icon
751-
const matches = matchesContiguous(query, wordToMatchAgainstWithoutIconsTrimmed, enableSeparateSubstringMatching);
753+
const matches = matchesContiguous(query, wordToMatchAgainstWithoutIconsTrimmed);
752754

753755
// Map matches back to offsets with icon and trimming
754756
if (matches) {
@@ -762,7 +764,7 @@ export function matchesContiguousIconAware(query: string, target: IParsedLabelWi
762764
return matches;
763765
}
764766

765-
function matchesContiguous(word: string, wordToMatchAgainst: string, enableSeparateSubstringMatching = false): IMatch[] | null {
767+
function matchesContiguous(word: string, wordToMatchAgainst: string): IMatch[] | null {
766768
const matchIndex = wordToMatchAgainst.toLowerCase().indexOf(word.toLowerCase());
767769
if (matchIndex !== -1) {
768770
return [{ start: matchIndex, end: matchIndex + word.length }];

0 commit comments

Comments
 (0)