提交 6307df69 编写于 作者: J Johannes Rieken

fix #50879

上级 4e047b55
......@@ -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) {
......
......@@ -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`
......
......@@ -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 };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册