diff --git a/src/vs/base/common/filters.ts b/src/vs/base/common/filters.ts index b268681d0c397f4cf68d394bdbfa85303628a6a5..7e32aa6e0832c89c7a8b0143781be91dddd59a33 100644 --- a/src/vs/base/common/filters.ts +++ b/src/vs/base/common/filters.ts @@ -341,7 +341,7 @@ export function matchesFuzzy(word: string, wordToMatchAgainst: string, enableSep return enableSeparateSubstringMatching ? fuzzySeparateFilter(word, wordToMatchAgainst) : fuzzyContiguousFilter(word, wordToMatchAgainst); } -export function skipScore(pattern: string, word: string, patternMaxWhitespaceIgnore?: number): [number, number[]] { +export function anyScore(pattern: string, word: string, patternMaxWhitespaceIgnore?: number): FuzzyScore { pattern = pattern.toLowerCase(); word = word.toLowerCase(); @@ -452,7 +452,9 @@ function isWhitespaceAtPos(value: string, index: number): boolean { const enum Arrow { Top = 0b1, Diag = 0b10, Left = 0b100 } -export function fuzzyScore(pattern: string, word: string, patternMaxWhitespaceIgnore?: number): [number, number[]] { +export type FuzzyScore = [number, number[]]; + +export function fuzzyScore(pattern: string, word: string, patternMaxWhitespaceIgnore?: number): FuzzyScore { const patternLen = pattern.length > 100 ? 100 : pattern.length; const wordLen = word.length > 100 ? 100 : word.length; @@ -715,15 +717,15 @@ class LazyArray { //#region --- graceful --- -export function fuzzyScoreGracefulAggressive(pattern: string, word: string, patternMaxWhitespaceIgnore?: number): [number, number[]] { +export function fuzzyScoreGracefulAggressive(pattern: string, word: string, patternMaxWhitespaceIgnore?: number): FuzzyScore { return fuzzyScoreWithPermutations(pattern, word, true, patternMaxWhitespaceIgnore); } -export function fuzzyScoreGraceful(pattern: string, word: string, patternMaxWhitespaceIgnore?: number): [number, number[]] { +export function fuzzyScoreGraceful(pattern: string, word: string, patternMaxWhitespaceIgnore?: number): FuzzyScore { return fuzzyScoreWithPermutations(pattern, word, false, patternMaxWhitespaceIgnore); } -function fuzzyScoreWithPermutations(pattern: string, word: string, aggressive?: boolean, patternMaxWhitespaceIgnore?: number): [number, number[]] { +function fuzzyScoreWithPermutations(pattern: string, word: string, aggressive?: boolean, patternMaxWhitespaceIgnore?: number): FuzzyScore { let top: [number, number[]] = fuzzyScore(pattern, word, patternMaxWhitespaceIgnore); if (top && !aggressive) { diff --git a/src/vs/editor/contrib/suggest/completionModel.ts b/src/vs/editor/contrib/suggest/completionModel.ts index 58b95c31146516011eb1a4138f9c59fb8b11419c..255750fe219a32cfa5929817e0a24c9bd5f6351c 100644 --- a/src/vs/editor/contrib/suggest/completionModel.ts +++ b/src/vs/editor/contrib/suggest/completionModel.ts @@ -5,7 +5,7 @@ 'use strict'; -import { fuzzyScore, fuzzyScoreGracefulAggressive, skipScore } from 'vs/base/common/filters'; +import { fuzzyScore, fuzzyScoreGracefulAggressive, anyScore } from 'vs/base/common/filters'; import { isDisposable } from 'vs/base/common/lifecycle'; import { ISuggestResult, ISuggestSupport } from 'vs/editor/common/modes'; import { ISuggestionItem, SnippetConfig } from './suggest'; @@ -191,7 +191,7 @@ export class CompletionModel { continue; } item.score = match[0]; - item.matches = skipScore(word, suggestion.label)[1]; + item.matches = (fuzzyScore(word, suggestion.label) || anyScore(word, suggestion.label))[1]; } else { // by default match `word` against the `label` diff --git a/src/vs/workbench/parts/outline/electron-browser/outlineModel.ts b/src/vs/workbench/parts/outline/electron-browser/outlineModel.ts index 2f02c46a0e9da70083927d1a636560a73d61a80d..7a3c109e48ca87568e3ac81a8e18ba2a6664669b 100644 --- a/src/vs/workbench/parts/outline/electron-browser/outlineModel.ts +++ b/src/vs/workbench/parts/outline/electron-browser/outlineModel.ts @@ -8,15 +8,13 @@ import { DocumentSymbolProviderRegistry, SymbolInformation, DocumentSymbolProvid import { ITextModel } from 'vs/editor/common/model'; import { asWinJsPromise } from 'vs/base/common/async'; import { TPromise } from 'vs/base/common/winjs.base'; -import { fuzzyScore } from 'vs/base/common/filters'; +import { fuzzyScore, FuzzyScore } from 'vs/base/common/filters'; import { IPosition } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; import { first, size } from 'vs/base/common/collections'; import { isFalsyOrEmpty } from 'vs/base/common/arrays'; import { commonPrefixLength } from 'vs/base/common/strings'; -export type FuzzyScore = [number, number[]]; - export abstract class TreeElement { abstract id: string; abstract children: { [id: string]: TreeElement };