diff --git a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts index 026883bd5826ca8ba060c61d83b3985812de86ea..db7121a3340a0ff70dd2f005286a74f9333c7331 100644 --- a/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts +++ b/src/vs/workbench/browser/parts/quickopen/quickOpenController.ts @@ -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(); } } diff --git a/src/vs/workbench/browser/workbench.ts b/src/vs/workbench/browser/workbench.ts index c809ce7d63f2745af0cc20f7e90958b959826812..2be25450b4d0037581802d005213b65eef8b4a39 100644 --- a/src/vs/workbench/browser/workbench.ts +++ b/src/vs/workbench/browser/workbench.ts @@ -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) { (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); diff --git a/src/vs/workbench/electron-browser/main.contribution.ts b/src/vs/workbench/electron-browser/main.contribution.ts index 1f5d28cf0edc436f0550c551a78c1672418c0b02..b9b510ba41916f376e7f1e6cb72eba4d43592681 100644 --- a/src/vs/workbench/electron-browser/main.contribution.ts +++ b/src/vs/workbench/electron-browser/main.contribution.ts @@ -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 diff --git a/src/vs/workbench/parts/quickopen/browser/quickopen.contribution.ts b/src/vs/workbench/parts/quickopen/browser/quickopen.contribution.ts index 73c9ae80361ca0fa7af53d628f8db33fcd737735..3d9e1440d6fc24e78f2526249b15e52cf79ef413 100644 --- a/src/vs/workbench/parts/quickopen/browser/quickopen.contribution.ts +++ b/src/vs/workbench/parts/quickopen/browser/quickopen.contribution.ts @@ -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 = 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 diff --git a/src/vs/workbench/services/quickopen/browser/quickOpenService.ts b/src/vs/workbench/services/quickopen/browser/quickOpenService.ts index ece782330ab52d3a3598d5e057cd86df8133ee37..50f260bccb6e39f4b3c82d3b445b5ba30c6eed5a 100644 --- a/src/vs/workbench/services/quickopen/browser/quickOpenService.ts +++ b/src/vs/workbench/services/quickopen/browser/quickOpenService.ts @@ -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 diff --git a/src/vs/workbench/test/browser/parts/quickOpen/quickopen.test.ts b/src/vs/workbench/test/browser/parts/quickOpen/quickopen.test.ts index d6f1a79f9a88fe90a233668f8e970896221b98ee..2406221601d6f8e3a94242d13b3bf74d58bdf726 100644 --- a/src/vs/workbench/test/browser/parts/quickOpen/quickopen.test.ts +++ b/src/vs/workbench/test/browser/parts/quickOpen/quickopen.test.ts @@ -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() ); diff --git a/src/vs/workbench/test/browser/servicesTestUtils.ts b/src/vs/workbench/test/browser/servicesTestUtils.ts index c81b5136c65e252100e56fbbdd4ba64676c596a7..a0578a4222483aa449d5a6b9f00ab730d7ef2e0a 100644 --- a/src/vs/workbench/test/browser/servicesTestUtils.ts +++ b/src/vs/workbench/test/browser/servicesTestUtils.ts @@ -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 { + return TPromise.as({}); + } + + public hasWorkspaceConfiguration():boolean { + return false; + } } \ No newline at end of file