diff --git a/src/vs/editor/common/controller/coreCommands.ts b/src/vs/editor/browser/controller/coreCommands.ts similarity index 100% rename from src/vs/editor/common/controller/coreCommands.ts rename to src/vs/editor/browser/controller/coreCommands.ts diff --git a/src/vs/editor/browser/view/viewController.ts b/src/vs/editor/browser/view/viewController.ts index e44a5286665..f817cd36c73 100644 --- a/src/vs/editor/browser/view/viewController.ts +++ b/src/vs/editor/browser/view/viewController.ts @@ -12,7 +12,7 @@ import { IEditorMouseEvent } from 'vs/editor/browser/editorBrowser'; import { ICommandService } from 'vs/platform/commands/common/commands'; import { IViewModel } from 'vs/editor/common/viewModel/viewModel'; import { ViewOutgoingEvents } from 'vs/editor/browser/view/viewOutgoingEvents'; -import { CoreNavigationCommands, CoreEditorCommand } from 'vs/editor/common/controller/coreCommands'; +import { CoreNavigationCommands, CoreEditorCommand } from 'vs/editor/browser/controller/coreCommands'; import { Configuration } from 'vs/editor/browser/config/configuration'; export interface ExecCoreEditorCommandFunc { diff --git a/src/vs/editor/browser/widget/codeEditorWidget.ts b/src/vs/editor/browser/widget/codeEditorWidget.ts index b28ce04f4f7..ac72b370378 100644 --- a/src/vs/editor/browser/widget/codeEditorWidget.ts +++ b/src/vs/editor/browser/widget/codeEditorWidget.ts @@ -27,7 +27,7 @@ import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { InternalEditorAction } from 'vs/editor/common/editorAction'; import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { IPosition } from 'vs/editor/common/core/position'; -import { CoreEditorCommand } from 'vs/editor/common/controller/coreCommands'; +import { CoreEditorCommand } from 'vs/editor/browser/controller/coreCommands'; import { IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService'; import { editorErrorForeground, editorErrorBorder, editorWarningForeground, editorWarningBorder, editorInfoBorder, editorInfoForeground } from 'vs/editor/common/view/editorColorRegistry'; import { Color } from 'vs/base/common/color'; diff --git a/src/vs/editor/contrib/find/test/findModel.test.ts b/src/vs/editor/contrib/find/test/findModel.test.ts index f6b0aec8309..fb14ac72aeb 100644 --- a/src/vs/editor/contrib/find/test/findModel.test.ts +++ b/src/vs/editor/contrib/find/test/findModel.test.ts @@ -13,7 +13,7 @@ import { ICommonCodeEditor } from 'vs/editor/common/editorCommon'; import { FindModelBoundToEditorModel } from 'vs/editor/contrib/find/findModel'; import { FindReplaceState } from 'vs/editor/contrib/find/findState'; import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; -import { CoreNavigationCommands } from 'vs/editor/common/controller/coreCommands'; +import { CoreNavigationCommands } from 'vs/editor/browser/controller/coreCommands'; suite('FindModel', () => { diff --git a/src/vs/editor/contrib/linesOperations/linesOperations.ts b/src/vs/editor/contrib/linesOperations/linesOperations.ts index 9db391706aa..e0d46569a04 100644 --- a/src/vs/editor/contrib/linesOperations/linesOperations.ts +++ b/src/vs/editor/contrib/linesOperations/linesOperations.ts @@ -20,7 +20,7 @@ import { CopyLinesCommand } from './copyLinesCommand'; import { DeleteLinesCommand } from './deleteLinesCommand'; import { MoveLinesCommand } from './moveLinesCommand'; import { TypeOperations } from 'vs/editor/common/controller/cursorTypeOperations'; -import { CoreEditingCommands } from 'vs/editor/common/controller/coreCommands'; +import { CoreEditingCommands } from 'vs/editor/browser/controller/coreCommands'; // copy lines diff --git a/src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts b/src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts index c20ab53465a..f3ae3bfdd1e 100644 --- a/src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts +++ b/src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts @@ -12,7 +12,7 @@ import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { DeleteAllLeftAction, JoinLinesAction, TransposeAction, UpperCaseAction, LowerCaseAction, DeleteAllRightAction, InsertLineBeforeAction, InsertLineAfterAction, IndentLinesAction } from 'vs/editor/contrib/linesOperations/linesOperations'; import { Cursor } from 'vs/editor/common/controller/cursor'; import { Model } from 'vs/editor/common/model/model'; -import { CoreEditingCommands } from 'vs/editor/common/controller/coreCommands'; +import { CoreEditingCommands } from 'vs/editor/browser/controller/coreCommands'; suite('Editor Contrib - Line Operations', () => { suite('DeleteAllLeftAction', () => { diff --git a/src/vs/editor/editor.all.ts b/src/vs/editor/editor.all.ts index 094db4a748d..3d2805ef2b9 100644 --- a/src/vs/editor/editor.all.ts +++ b/src/vs/editor/editor.all.ts @@ -5,7 +5,7 @@ 'use strict'; -import 'vs/editor/common/controller/coreCommands'; +import 'vs/editor/browser/controller/coreCommands'; import 'vs/editor/browser/widget/codeEditorWidget'; import 'vs/editor/browser/widget/diffEditorWidget'; import 'vs/editor/browser/widget/diffNavigator'; diff --git a/src/vs/editor/test/browser/controller/cursor.test.ts b/src/vs/editor/test/browser/controller/cursor.test.ts index e23fea93877..08385c950c0 100644 --- a/src/vs/editor/test/browser/controller/cursor.test.ts +++ b/src/vs/editor/test/browser/controller/cursor.test.ts @@ -22,7 +22,7 @@ import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration import { MockMode } from 'vs/editor/test/common/mocks/mockMode'; import { LanguageIdentifier } from 'vs/editor/common/modes'; import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; -import { CoreNavigationCommands, CoreEditingCommands } from 'vs/editor/common/controller/coreCommands'; +import { CoreNavigationCommands, CoreEditingCommands } from 'vs/editor/browser/controller/coreCommands'; import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor'; import { TextModel } from 'vs/editor/common/model/textModel'; import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl'; diff --git a/src/vs/editor/test/common/controller/cursorMoveCommand.test.ts b/src/vs/editor/test/browser/controller/cursorMoveCommand.test.ts similarity index 99% rename from src/vs/editor/test/common/controller/cursorMoveCommand.test.ts rename to src/vs/editor/test/browser/controller/cursorMoveCommand.test.ts index 57fe5b79395..d5b71afd602 100644 --- a/src/vs/editor/test/common/controller/cursorMoveCommand.test.ts +++ b/src/vs/editor/test/browser/controller/cursorMoveCommand.test.ts @@ -12,7 +12,7 @@ import { TestConfiguration } from 'vs/editor/test/common/mocks/testConfiguration import { CursorMove } from 'vs/editor/common/controller/cursorMoveCommands'; import { Range } from 'vs/editor/common/core/range'; import { Selection } from 'vs/editor/common/core/selection'; -import { CoreNavigationCommands } from 'vs/editor/common/controller/coreCommands'; +import { CoreNavigationCommands } from 'vs/editor/browser/controller/coreCommands'; import { ViewModel } from 'vs/editor/common/viewModel/viewModelImpl'; suite('Cursor move command test', () => { diff --git a/src/vs/workbench/parts/debug/electron-browser/debugEditorContribution.ts b/src/vs/workbench/parts/debug/electron-browser/debugEditorContribution.ts index bfcc0c47d8a..2c239e57d45 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugEditorContribution.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugEditorContribution.ts @@ -37,7 +37,7 @@ import { FloatingClickWidget } from 'vs/workbench/parts/preferences/browser/pref import { IListService } from 'vs/platform/list/browser/listService'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { Position } from 'vs/editor/common/core/position'; -import { CoreEditingCommands } from 'vs/editor/common/controller/coreCommands'; +import { CoreEditingCommands } from 'vs/editor/browser/controller/coreCommands'; import { first } from 'vs/base/common/arrays'; import { IMarginData } from 'vs/editor/browser/controller/mouseTarget'; diff --git a/src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts b/src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts index b594c4cfff0..a8d6a2a6d0e 100644 --- a/src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts +++ b/src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts @@ -41,6 +41,7 @@ import { KeyCode, ResolvedKeybinding } from 'vs/base/common/keyCodes'; import { attachListStyler } from 'vs/platform/theme/common/styler'; import { listHighlightForeground } from 'vs/platform/theme/common/colorRegistry'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; +import { CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions'; let $ = DOM.$; @@ -350,7 +351,13 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor if (this.input) { return this.input.resolve() .then((keybindingsModel: KeybindingsEditorModel) => this.keybindingsEditorModel = keybindingsModel) - .then(() => this.keybindingsEditorModel.resolve()) + .then(() => { + const editorActionsLabels: { [id: string]: string; } = CommonEditorRegistry.getEditorActions().reduce((editorActions, editorAction) => { + editorActions[editorAction.id] = editorAction.label; + return editorActions; + }, {}); + return this.keybindingsEditorModel.resolve(editorActionsLabels); + }) .then(() => this.renderKeybindingsEntries(false)); } return TPromise.as(null); @@ -823,4 +830,4 @@ registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => { if (listHighlightForegroundColor) { collector.addRule(`.keybindings-editor > .keybindings-body > .keybindings-list-container .monaco-list-row > .column .highlight { color: ${listHighlightForegroundColor}; }`); } -}); \ No newline at end of file +}); diff --git a/src/vs/workbench/parts/preferences/common/keybindingsEditorModel.ts b/src/vs/workbench/parts/preferences/common/keybindingsEditorModel.ts index 65e93c3b212..02ef801dbdf 100644 --- a/src/vs/workbench/parts/preferences/common/keybindingsEditorModel.ts +++ b/src/vs/workbench/parts/preferences/common/keybindingsEditorModel.ts @@ -12,7 +12,6 @@ import { IMatch, IFilter, or, matchesContiguousSubString, matchesPrefix, matches import { Registry } from 'vs/platform/registry/common/platform'; import { ResolvedKeybinding, ResolvedKeybindingPart } from 'vs/base/common/keyCodes'; import { AriaLabelProvider, UserSettingsLabelProvider, UILabelProvider, ModifierLabels as ModLabels } from 'vs/base/common/keybindingLabels'; -import { CommonEditorRegistry, EditorAction } from 'vs/editor/common/editorCommonExtensions'; import { MenuRegistry, ILocalizedString, ICommandAction } from 'vs/platform/actions/common/actions'; import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions'; import { EditorModel } from 'vs/workbench/common/editor'; @@ -144,20 +143,16 @@ export class KeybindingsEditorModel extends EditorModel { return result; } - public resolve(): TPromise { + public resolve(editorActionsLabels: { [id: string]: string; }): TPromise { return this.extensionService.onReady() .then(() => { const workbenchActionsRegistry = Registry.as(ActionExtensions.WorkbenchActions); - const editorActions = CommonEditorRegistry.getEditorActions().reduce((editorActions, editorAction) => { - editorActions[editorAction.id] = editorAction; - return editorActions; - }, {}); this._keybindingItemsSortedByPrecedence = []; const boundCommands: Map = new Map(); for (const keybinding of this.keybindingsService.getKeybindings()) { if (keybinding.command) { // Skip keybindings without commands - this._keybindingItemsSortedByPrecedence.push(KeybindingsEditorModel.toKeybindingEntry(keybinding.command, keybinding, workbenchActionsRegistry, editorActions)); + this._keybindingItemsSortedByPrecedence.push(KeybindingsEditorModel.toKeybindingEntry(keybinding.command, keybinding, workbenchActionsRegistry, editorActionsLabels)); boundCommands.set(keybinding.command, true); } } @@ -165,7 +160,7 @@ export class KeybindingsEditorModel extends EditorModel { const commandsWithDefaultKeybindings = this.keybindingsService.getDefaultKeybindings().map(keybinding => keybinding.command); for (const command of KeybindingResolver.getAllUnboundCommands(boundCommands)) { const keybindingItem = new ResolvedKeybindingItem(null, command, null, null, commandsWithDefaultKeybindings.indexOf(command) === -1); - this._keybindingItemsSortedByPrecedence.push(KeybindingsEditorModel.toKeybindingEntry(command, keybindingItem, workbenchActionsRegistry, editorActions)); + this._keybindingItemsSortedByPrecedence.push(KeybindingsEditorModel.toKeybindingEntry(command, keybindingItem, workbenchActionsRegistry, editorActionsLabels)); } this._keybindingItems = this._keybindingItemsSortedByPrecedence.slice(0).sort((a, b) => KeybindingsEditorModel.compareKeybindingData(a, b)); return this; @@ -200,14 +195,14 @@ export class KeybindingsEditorModel extends EditorModel { return a.command.localeCompare(b.command); } - private static toKeybindingEntry(command: string, keybindingItem: ResolvedKeybindingItem, workbenchActionsRegistry: IWorkbenchActionRegistry, editorActions: {}): IKeybindingItem { + private static toKeybindingEntry(command: string, keybindingItem: ResolvedKeybindingItem, workbenchActionsRegistry: IWorkbenchActionRegistry, editorActions: { [id: string]: string; }): IKeybindingItem { const menuCommand = MenuRegistry.getCommand(command); - const editorAction: EditorAction = editorActions[command]; + const editorActionLabel = editorActions[command]; return { keybinding: keybindingItem.resolvedKeybinding, keybindingItem, command, - commandLabel: KeybindingsEditorModel.getCommandLabel(menuCommand, editorAction), + commandLabel: KeybindingsEditorModel.getCommandLabel(menuCommand, editorActionLabel), commandDefaultLabel: KeybindingsEditorModel.getCommandDefaultLabel(menuCommand, workbenchActionsRegistry), when: keybindingItem.when ? keybindingItem.when.serialize() : '', source: keybindingItem.isDefault ? localize('default', "Default") : localize('user', "User") @@ -223,13 +218,13 @@ export class KeybindingsEditorModel extends EditorModel { return null; } - private static getCommandLabel(menuCommand: ICommandAction, editorAction: EditorAction): string { + private static getCommandLabel(menuCommand: ICommandAction, editorActionLabel: string): string { if (menuCommand) { return typeof menuCommand.title === 'string' ? menuCommand.title : menuCommand.title.value; } - if (editorAction) { - return editorAction.label; + if (editorActionLabel) { + return editorActionLabel; } return ''; diff --git a/src/vs/workbench/parts/preferences/test/common/keybindingsEditorModel.test.ts b/src/vs/workbench/parts/preferences/test/common/keybindingsEditorModel.test.ts index 38b61c6bce2..0317981f285 100644 --- a/src/vs/workbench/parts/preferences/test/common/keybindingsEditorModel.test.ts +++ b/src/vs/workbench/parts/preferences/test/common/keybindingsEditorModel.test.ts @@ -57,7 +57,7 @@ suite('Keybindings Editor Model test', () => { aResolvedKeybindingItem({ command: 'b' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape }, chordPart: { keyCode: KeyCode.Escape } }) ); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actuals = asResolvedKeybindingItems(testObject.fetch('')); assertKeybindingItems(actuals, expected); }); @@ -69,7 +69,7 @@ suite('Keybindings Editor Model test', () => { aResolvedKeybindingItem({ command: 'b' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape }, chordPart: { keyCode: KeyCode.Escape } }) ); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actuals = asResolvedKeybindingItems(testObject.fetch('').slice(0, 2), true); assertKeybindingItems(actuals, expected); }); @@ -83,7 +83,7 @@ suite('Keybindings Editor Model test', () => { ); const expected = [keybindings[2], keybindings[0], keybindings[1]]; - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actuals = asResolvedKeybindingItems(testObject.fetch('')); assertKeybindingItems(actuals, expected); }); @@ -97,7 +97,7 @@ suite('Keybindings Editor Model test', () => { ); const expected = [keybindings[1], keybindings[0]]; - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actuals = asResolvedKeybindingItems(testObject.fetch('')); assertKeybindingItems(actuals, expected); }); @@ -118,7 +118,7 @@ suite('Keybindings Editor Model test', () => { instantiationService.stub(IKeybindingService, 'getKeybindings', () => keybindings); instantiationService.stub(IKeybindingService, 'getDefaultKeybindings', () => keybindings); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actuals = asResolvedKeybindingItems(testObject.fetch('')); assertKeybindingItems(actuals, expected); }); @@ -137,7 +137,7 @@ suite('Keybindings Editor Model test', () => { registerCommandWithTitle(keybindings[3].command, 'Same Title'); const expected = [keybindings[3], keybindings[1], keybindings[0], keybindings[2]]; - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actuals = asResolvedKeybindingItems(testObject.fetch('')); assertKeybindingItems(actuals, expected); }); @@ -150,7 +150,7 @@ suite('Keybindings Editor Model test', () => { aResolvedKeybindingItem({ command: 'a' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Backspace } }) ); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actuals = asResolvedKeybindingItems(testObject.fetch('', true)); assertKeybindingItems(actuals, expected); }); @@ -160,7 +160,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command: 'a' + uuid.generateUuid(), firstPart: { keyCode: KeyCode.Escape }, when: 'context1 && context2' }); prepareKeybindingService(expected); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('')[0]; assert.equal(actual.keybindingItem.command, expected.command); assert.equal(actual.keybindingItem.commandLabel, ''); @@ -175,7 +175,7 @@ suite('Keybindings Editor Model test', () => { prepareKeybindingService(expected); registerCommandWithTitle(expected.command, 'Some Title'); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('')[0]; assert.equal(actual.keybindingItem.command, expected.command); assert.equal(actual.keybindingItem.commandLabel, 'Some Title'); @@ -189,7 +189,7 @@ suite('Keybindings Editor Model test', () => { CommandsRegistry.registerCommand('command_without_keybinding', () => { }); prepareKeybindingService(); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('').filter(element => element.keybindingItem.command === 'command_without_keybinding')[0]; assert.equal(actual.keybindingItem.command, 'command_without_keybinding'); assert.equal(actual.keybindingItem.commandLabel, ''); @@ -204,7 +204,7 @@ suite('Keybindings Editor Model test', () => { registerCommandWithTitle(id, 'some title'); prepareKeybindingService(); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('').filter(element => element.keybindingItem.command === id)[0]; assert.equal(actual.keybindingItem.command, id); assert.equal(actual.keybindingItem.commandLabel, 'some title'); @@ -219,7 +219,7 @@ suite('Keybindings Editor Model test', () => { registerCommandWithTitle(id, 'some title'); prepareKeybindingService(); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('workbench action view size').filter(element => element.keybindingItem.command === id)[0]; assert.ok(actual); }); @@ -230,7 +230,7 @@ suite('Keybindings Editor Model test', () => { registerCommandWithTitle(id, 'Increase view size'); prepareKeybindingService(); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('increase size').filter(element => element.keybindingItem.command === id)[0]; assert.ok(actual); }); @@ -241,7 +241,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape }, when: 'context1 && context2' }); prepareKeybindingService(expected); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('default').filter(element => element.keybindingItem.command === command)[0]; assert.ok(actual); }); @@ -252,7 +252,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape }, when: 'context1 && context2', isDefault: false }); prepareKeybindingService(expected); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('user').filter(element => element.keybindingItem.command === command)[0]; assert.ok(actual); }); @@ -263,7 +263,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('when context').filter(element => element.keybindingItem.command === command)[0]; assert.ok(actual); }); @@ -276,7 +276,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('cmd').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); @@ -291,7 +291,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('meta').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); @@ -306,7 +306,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { altKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('command').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); @@ -321,7 +321,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('windows').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); @@ -334,7 +334,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { altKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('alt').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true }); @@ -347,7 +347,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { altKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('option').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true }); @@ -360,7 +360,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('ctrl').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true }); @@ -373,7 +373,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('control').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true }); @@ -386,7 +386,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('shift').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true }); @@ -399,7 +399,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.RightArrow, modifiers: { shiftKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('arrow').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { keyCode: true }); @@ -412,7 +412,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.RightArrow, modifiers: { altKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.RightArrow, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('alt right').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true, keyCode: true }); @@ -425,7 +425,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.RightArrow, modifiers: { altKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.RightArrow, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('right alt').filter(element => element.keybindingItem.command === command); assert.equal(0, actual.length); }); @@ -437,7 +437,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { altKey: true, metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('alt cmd esc').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { altKey: true, metaKey: true, keyCode: true }); @@ -451,7 +451,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('cmd shift esc').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true, shiftKey: true, keyCode: true }); @@ -465,7 +465,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.Delete }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('cmd shift esc').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true, shiftKey: true, keyCode: true }); @@ -479,7 +479,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.Delete }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('cmd del').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { metaKey: true }); @@ -493,7 +493,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.Delete }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.UpArrow }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('cmd shift esc del').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true, metaKey: true, keyCode: true }); @@ -506,7 +506,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.KEY_C, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.KEY_C, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('"ctrl c"').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true, keyCode: true }); @@ -519,7 +519,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.KEY_C, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.KEY_C, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('"shift meta escape ctrl c"').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true, metaKey: true, keyCode: true }); @@ -533,7 +533,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.Delete, modifiers: { metaKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.UpArrow }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('"cmd shift esc del"').filter(element => element.keybindingItem.command === command); assert.equal(0, actual.length); }); @@ -544,7 +544,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.KEY_C, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.KEY_C, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('"control+c"').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { ctrlKey: true, keyCode: true }); @@ -557,7 +557,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Escape, modifiers: { shiftKey: true, metaKey: true } }, chordPart: { keyCode: KeyCode.KEY_C, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.KEY_C, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('"shift+meta+escape ctrl+c"').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); assert.deepEqual(actual[0].keybindingMatches.firstPart, { shiftKey: true, metaKey: true, keyCode: true }); @@ -570,7 +570,7 @@ suite('Keybindings Editor Model test', () => { const expected = aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Space, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false }); prepareKeybindingService(expected, aResolvedKeybindingItem({ command, firstPart: { keyCode: KeyCode.Backspace, modifiers: { ctrlKey: true } }, when: 'whenContext1 && whenContext2', isDefault: false })); - return testObject.resolve().then(() => { + return testObject.resolve({}).then(() => { const actual = testObject.fetch('"ctrl+space"').filter(element => element.keybindingItem.command === command); assert.equal(1, actual.length); }); @@ -630,4 +630,4 @@ suite('Keybindings Editor Model test', () => { } -}); \ No newline at end of file +}); diff --git a/src/vs/workbench/parts/search/browser/search.contribution.ts b/src/vs/workbench/parts/search/browser/search.contribution.ts index a8eddf21c3d..a43371bd1d3 100644 --- a/src/vs/workbench/parts/search/browser/search.contribution.ts +++ b/src/vs/workbench/parts/search/browser/search.contribution.ts @@ -45,6 +45,9 @@ import { IOutputChannelRegistry, Extensions as OutputExt } from 'vs/workbench/pa import { defaultQuickOpenContextKey } from 'vs/workbench/browser/parts/quickopen/quickopen'; import { OpenSymbolHandler } from 'vs/workbench/parts/search/browser/openSymbolHandler'; import { OpenAnythingHandler } from 'vs/workbench/parts/search/browser/openAnythingHandler'; +import { CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions'; +import { getWorkspaceSymbols } from 'vs/workbench/parts/search/common/search'; +import { illegalArgument } from 'vs/base/common/errors'; registerSingleton(ISearchWorkbenchService, SearchWorkbenchService); replaceContributions(); @@ -416,3 +419,11 @@ configurationRegistry.registerConfiguration({ } } }); + +CommonEditorRegistry.registerLanguageCommand('_executeWorkspaceSymbolProvider', function (accessor, args: { query: string; }) { + let { query } = args; + if (typeof query !== 'string') { + throw illegalArgument(); + } + return getWorkspaceSymbols(query); +}); diff --git a/src/vs/workbench/parts/search/common/search.ts b/src/vs/workbench/parts/search/common/search.ts index e2f821151e4..b70c9d372c4 100644 --- a/src/vs/workbench/parts/search/common/search.ts +++ b/src/vs/workbench/parts/search/common/search.ts @@ -6,9 +6,8 @@ 'use strict'; import { TPromise } from 'vs/base/common/winjs.base'; -import { onUnexpectedError, illegalArgument } from 'vs/base/common/errors'; +import { onUnexpectedError } from 'vs/base/common/errors'; import { IDisposable } from 'vs/base/common/lifecycle'; -import { CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions'; import { ISearchConfiguration } from 'vs/platform/search/common/search'; import glob = require('vs/base/common/glob'); import { SymbolInformation } from 'vs/editor/common/modes'; @@ -65,14 +64,6 @@ export function getWorkspaceSymbols(query: string): TPromise<[IWorkspaceSymbolPr return TPromise.join(promises).then(_ => result); } -CommonEditorRegistry.registerLanguageCommand('_executeWorkspaceSymbolProvider', function (accessor, args: { query: string; }) { - let { query } = args; - if (typeof query !== 'string') { - throw illegalArgument(); - } - return getWorkspaceSymbols(query); -}); - export interface IWorkbenchSearchConfiguration extends ISearchConfiguration { search: { quickOpen: { @@ -109,4 +100,4 @@ export function getOutOfWorkspaceEditorResources(editorGroupService: IEditorGrou }); return resources; -} \ No newline at end of file +} diff --git a/src/vs/workbench/test/browser/parts/editor/rangeDecorations.test.ts b/src/vs/workbench/test/browser/parts/editor/rangeDecorations.test.ts index f55b059cac9..b2743d1d4cf 100644 --- a/src/vs/workbench/test/browser/parts/editor/rangeDecorations.test.ts +++ b/src/vs/workbench/test/browser/parts/editor/rangeDecorations.test.ts @@ -23,7 +23,7 @@ import { Position } from 'vs/editor/common/core/position'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl'; -import { CoreNavigationCommands } from 'vs/editor/common/controller/coreCommands'; +import { CoreNavigationCommands } from 'vs/editor/browser/controller/coreCommands'; suite('Editor - Range decorations', () => {