提交 f9c0e7b7 编写于 作者: B Benjamin Pasero

Introduce a new setting to enable fuzzy for pickers

上级 65a35be7
......@@ -13,6 +13,7 @@ import strings = require('vs/base/common/strings');
import filters = require('vs/base/common/filters');
import uuid = require('vs/base/common/uuid');
import types = require('vs/base/common/types');
import {ListenerUnbind} from 'vs/base/common/eventEmitter';
import {Mode, IContext, IAutoFocus, IQuickNavigateConfiguration, IModel} from 'vs/base/parts/quickopen/browser/quickOpen';
import {QuickOpenEntryItem, QuickOpenEntry, QuickOpenModel, QuickOpenEntryGroup} from 'vs/base/parts/quickopen/browser/quickOpenModel';
import {QuickOpenWidget} from 'vs/base/parts/quickopen/browser/quickOpenWidget';
......@@ -38,8 +39,9 @@ import {IEventService} from 'vs/platform/event/common/event';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {IMessageService, Severity} from 'vs/platform/message/common/message';
import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
import {IWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService';
import {IKeybindingService, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybindingService';
import {IConfigurationService, IConfigurationServiceEvent, ConfigurationServiceEventTypes} from 'vs/platform/configuration/common/configuration';
const ID = 'workbench.component.quickopen';
const EDITOR_HISTORY_STORAGE_KEY = 'quickopen.editorhistory';
......@@ -77,6 +79,8 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
private actionProvider = new ContributableActionProvider();
private previousValue = '';
private visibilityChangeTimeoutHandle: number;
private fuzzyMatchingEnabled: boolean;
private configurationListenerUnbind: ListenerUnbind;
constructor(
private eventService: IEventService,
......@@ -86,6 +90,7 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
private messageService: IMessageService,
private telemetryService: ITelemetryService,
private contextService: IWorkspaceContextService,
private configurationService: IConfigurationService,
keybindingService: IKeybindingService
) {
super(ID);
......@@ -97,8 +102,22 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
this.inQuickOpenMode = keybindingService.createKey(QUICK_OPEN_MODE, false);
this.updateFuzzyMatching(contextService.getOptions().globalSettings.settings);
this._onShow = new EventSource<() => void>();
this._onHide = new EventSource<() => void>();
this.registerListeners();
}
private registerListeners(): void {
// Listen to configuration changes
this.configurationListenerUnbind = this.configurationService.addListener(ConfigurationServiceEventTypes.UPDATED, (e: IConfigurationServiceEvent) => this.updateFuzzyMatching(e.config));
}
private updateFuzzyMatching(configuration: any): void {
this.fuzzyMatchingEnabled = configuration.picker && configuration.picker.enableFuzzy;
}
public get onShow(): EventProvider<() => void> {
......@@ -117,6 +136,10 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
return this.editorHistoryModel;
}
public isFuzzyMatchingEnabled(): boolean {
return this.fuzzyMatchingEnabled;
}
public create(): void {
// Listen on Editor Input Changes to show in MRU List
......@@ -829,6 +852,10 @@ export class QuickOpenController extends WorkbenchComponent implements IQuickOpe
this.pickOpenWidget.dispose();
}
if (this.configurationListenerUnbind) {
this.configurationListenerUnbind();
}
super.dispose();
}
}
......
......@@ -29,6 +29,7 @@ import {HistoryService} from 'vs/workbench/services/history/browser/history';
import {ActivitybarPart} from 'vs/workbench/browser/parts/activitybar/activitybarPart';
import {EditorPart} from 'vs/workbench/browser/parts/editor/editorPart';
import {SidebarPart} from 'vs/workbench/browser/parts/sidebar/sidebarPart';
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import {StatusbarPart} from 'vs/workbench/browser/parts/statusbar/statusbarPart';
import {WorkbenchLayout, LayoutOptions} from 'vs/workbench/browser/layout';
import {IActionBarRegistry, Extensions as ActionBarExtensions} from 'vs/workbench/browser/actionBarRegistry';
......@@ -270,6 +271,7 @@ export class Workbench implements IPartService {
this.keybindingService = this.instantiationService.getInstance(IKeybindingService);
this.contextService = this.instantiationService.getInstance(IWorkbenchWorkspaceContextService);
this.telemetryService = this.instantiationService.getInstance(ITelemetryService);
let configurationService = this.instantiationService.getInstance(IConfigurationService);
let messageService = this.instantiationService.getInstance(IMessageService);
if (this.keybindingService instanceof AbstractKeybindingService) {
(<AbstractKeybindingService><any>this.keybindingService).setMessageService(messageService);
......@@ -339,6 +341,7 @@ export class Workbench implements IPartService {
messageService,
this.telemetryService,
this.contextService,
configurationService,
this.keybindingService
);
this.toDispose.push(this.quickOpen);
......
......@@ -79,4 +79,19 @@ configurationRegistry.registerConfiguration({
'description': nls.localize('updateChannel', "Configure the update channel to receive updates from. Requires a restart after change.")
},
}
});
// Picker Configuration
configurationRegistry.registerConfiguration({
'id': 'picker',
'order': 11,
'title': nls.localize('filterConfigurationTitle', "Picker configuration"),
'type': 'object',
'properties': {
'picker.enableFuzzy': {
'type': 'boolean',
'default': false,
'description': nls.localize('enableFuzzy', "Enable or disable fuzzy matching and sorting in the picker.")
}
}
});
\ No newline at end of file
......@@ -2,7 +2,7 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import env = require('vs/base/common/platform');
......@@ -107,20 +107,4 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(GotoSymbolAction, Goto
HELP_PREFIX,
nls.localize('helpDescription', "Show Help")
)
);
// Configuration
const configurationRegistry = <IConfigurationRegistry>Registry.as(ConfigurationExtensions.Configuration);
configurationRegistry.registerConfiguration({
'id': 'filter',
'order': 11,
'title': nls.localize('filterConfigurationTitle', "Filter configuration"),
'type': 'object',
'properties': {
'filter.enableFuzzy': {
'type': 'boolean',
'default': false,
'description': nls.localize('enableFuzzy', "Enable or disable fuzzy matching in controls that narrow down while typing.")
}
}
});
\ No newline at end of file
);
\ No newline at end of file
......@@ -125,4 +125,9 @@ export interface IQuickOpenService {
* Allows to register on the event that quick open is hiding
*/
onHide: EventProvider<() => void>;
/**
* A boolean to indicate if fuzzy matching is enabled or not.
*/
isFuzzyMatchingEnabled(): boolean;
}
\ No newline at end of file
......@@ -6,7 +6,7 @@
'use strict';
import * as assert from 'assert';
import {TestKeybindingService, TestContextService, TestStorageService, TestEventService, TestEditorService, TestQuickOpenService} from 'vs/workbench/test/browser/servicesTestUtils';
import {TestKeybindingService, TestConfigurationService, TestContextService, TestStorageService, TestEventService, TestEditorService, TestQuickOpenService} from 'vs/workbench/test/browser/servicesTestUtils';
import {Registry} from 'vs/platform/platform';
import {EditorHistoryModel, EditorHistoryEntry} from 'vs/workbench/browser/parts/quickopen/editorHistoryModel';
import {QuickOpenHandlerDescriptor, IQuickOpenRegistry, Extensions as QuickOpenExtensions} from 'vs/workbench/browser/quickopen';
......@@ -216,6 +216,7 @@ suite('Workbench QuickOpen', () => {
null,
null,
contextService,
new TestConfigurationService(),
new TestKeybindingService()
);
......
......@@ -27,6 +27,7 @@ import Severity from 'vs/base/common/severity';
import Arrays = require('vs/base/common/arrays');
import Errors = require('vs/base/common/errors');
import http = require('vs/base/common/http');
import {IConfigurationService} from 'vs/platform/configuration/common/configuration';
import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage';
import UntitledEditorService = require('vs/workbench/services/untitled/browser/untitledEditorService');
import WorkbenchEditorService = require('vs/workbench/services/editor/common/editorService');
......@@ -71,7 +72,11 @@ export class TestContextService implements WorkspaceContextService.IWorkspaceCon
constructor(workspace: any = TestWorkspace, configuration: any = TestConfiguration, options: any = null) {
this.workspace = workspace;
this.configuration = configuration;
this.options = options;
this.options = options || {
globalSettings: {
settings: {}
}
};
}
public getWorkspace(): IWorkspace {
......@@ -500,6 +505,10 @@ export class TestQuickOpenService implements QuickOpenService.IQuickOpenService
return null;
}
public isFuzzyMatchingEnabled(): boolean {
return false;
}
public removeEditorHistoryEntry(input: WorkbenchEditorCommon.EditorInput): void {}
public dispose() {}
public quickNavigate(): void {}
......@@ -530,4 +539,16 @@ export const TestFileService = {
};
});
}
}
export class TestConfigurationService extends EventEmitter.EventEmitter implements IConfigurationService {
public serviceId = IConfigurationService;
public loadConfiguration(section?:string):TPromise<any> {
return TPromise.as({});
}
public hasWorkspaceConfiguration():boolean {
return false;
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册