diff --git a/CHANGELOG.md b/CHANGELOG.md index ff769bfaf7fa7..03d3d63fe7ede 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Breaking changes: - [editor] computation of resource context keys moved to core [#4531](https://github.com/theia-ide/theia/pull/4531) +- [quick-open] disable separate fuzzy matching by default [#4549](https://github.com/theia-ide/theia/pull/4549) ## v0.4.0 - [application-manager] added support for pre-load HTML templates diff --git a/packages/core/src/browser/quick-open/quick-open-service.ts b/packages/core/src/browser/quick-open/quick-open-service.ts index b3069ca7281ce..61f68b2928e44 100644 --- a/packages/core/src/browser/quick-open/quick-open-service.ts +++ b/packages/core/src/browser/quick-open/quick-open-service.ts @@ -20,14 +20,20 @@ import { MessageType } from '../../common/message-service-protocol'; export type QuickOpenOptions = Partial; export namespace QuickOpenOptions { + export interface FuzzyMatchOptions { + /** + * Default: `false` + */ + enableSeparateSubstringMatching?: boolean + } export interface Resolved { readonly prefix: string; readonly placeholder: string; readonly ignoreFocusOut: boolean; - readonly fuzzyMatchLabel: boolean; - readonly fuzzyMatchDetail: boolean; - readonly fuzzyMatchDescription: boolean; + readonly fuzzyMatchLabel: boolean | FuzzyMatchOptions; + readonly fuzzyMatchDetail: boolean | FuzzyMatchOptions; + readonly fuzzyMatchDescription: boolean | FuzzyMatchOptions; readonly fuzzySort: boolean; /** The amount of first symbols to be ignored by quick open widget (e.g. don't affect matching). */ diff --git a/packages/file-search/src/browser/quick-file-open.ts b/packages/file-search/src/browser/quick-file-open.ts index 8b6f123150750..be72ceb9d1046 100644 --- a/packages/file-search/src/browser/quick-file-open.ts +++ b/packages/file-search/src/browser/quick-file-open.ts @@ -91,8 +91,12 @@ export class QuickFileOpenService implements QuickOpenModel, QuickOpenHandler { } return { placeholder, - fuzzyMatchLabel: true, - fuzzyMatchDescription: true, + fuzzyMatchLabel: { + enableSeparateSubstringMatching: true + }, + fuzzyMatchDescription: { + enableSeparateSubstringMatching: true + }, showItemsWithoutHighlight: true, onClose: () => { this.isOpen = false; diff --git a/packages/monaco/src/browser/monaco-quick-open-service.ts b/packages/monaco/src/browser/monaco-quick-open-service.ts index 7a0ecb255a4f5..6fc9d0e0ad530 100644 --- a/packages/monaco/src/browser/monaco-quick-open-service.ts +++ b/packages/monaco/src/browser/monaco-quick-open-service.ts @@ -244,9 +244,10 @@ export class MonacoQuickOpenControllerOptsImpl implements MonacoQuickOpenControl if (this.options.skipPrefix) { lookFor = lookFor.substr(this.options.skipPrefix); } - const labelHighlights = this.options.fuzzyMatchLabel ? this.matchesFuzzy(lookFor, item.getLabel()) : item.getLabelHighlights(); - const descriptionHighlights = this.options.fuzzyMatchDescription ? this.matchesFuzzy(lookFor, item.getDescription()) : item.getDescriptionHighlights(); - const detailHighlights = this.options.fuzzyMatchDetail ? this.matchesFuzzy(lookFor, item.getDetail()) : item.getDetailHighlights(); + const { fuzzyMatchLabel, fuzzyMatchDescription, fuzzyMatchDetail } = this.options; + const labelHighlights = fuzzyMatchLabel ? this.matchesFuzzy(lookFor, item.getLabel(), fuzzyMatchLabel) : item.getLabelHighlights(); + const descriptionHighlights = fuzzyMatchDescription ? this.matchesFuzzy(lookFor, item.getDescription(), fuzzyMatchDescription) : item.getDescriptionHighlights(); + const detailHighlights = fuzzyMatchDetail ? this.matchesFuzzy(lookFor, item.getDetail(), fuzzyMatchDetail) : item.getDetailHighlights(); if ((lookFor && !labelHighlights && !descriptionHighlights && !detailHighlights) && !this.options.showItemsWithoutHighlight) { return undefined; @@ -256,11 +257,12 @@ export class MonacoQuickOpenControllerOptsImpl implements MonacoQuickOpenControl return entry; } - protected matchesFuzzy(lookFor: string, value: string | undefined): monaco.quickOpen.IHighlight[] | undefined { + protected matchesFuzzy(lookFor: string, value: string | undefined, options?: QuickOpenOptions.FuzzyMatchOptions | boolean): monaco.quickOpen.IHighlight[] | undefined { if (!lookFor || !value) { return undefined; } - return monaco.filters.matchesFuzzy(lookFor, value, true); + const enableSeparateSubstringMatching = typeof options === 'object' && options.enableSeparateSubstringMatching; + return monaco.filters.matchesFuzzy(lookFor, value, enableSeparateSubstringMatching); } getAutoFocus(lookFor: string): monaco.quickOpen.IAutoFocus {