Reduce usages of editorCommonExtensions in /common/ (#37834)

This commit is contained in:
Alex Dima
2017-11-09 10:41:17 +01:00
parent b0e058ea98
commit 3d1ccaa440
16 changed files with 81 additions and 77 deletions

View File

@@ -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 {

View File

@@ -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';

View File

@@ -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', () => {

View File

@@ -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

View File

@@ -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', () => {

View File

@@ -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';

View File

@@ -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';

View File

@@ -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', () => {

View File

@@ -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';

View File

@@ -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}; }`);
}
});
});

View File

@@ -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<EditorModel> {
public resolve(editorActionsLabels: { [id: string]: string; }): TPromise<EditorModel> {
return this.extensionService.onReady()
.then(() => {
const workbenchActionsRegistry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
const editorActions = CommonEditorRegistry.getEditorActions().reduce((editorActions, editorAction) => {
editorActions[editorAction.id] = editorAction;
return editorActions;
}, {});
this._keybindingItemsSortedByPrecedence = [];
const boundCommands: Map<string, boolean> = new Map<string, boolean>();
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 <IKeybindingItem>{
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 '';

View File

@@ -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', () => {
}
});
});

View File

@@ -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);
});

View File

@@ -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;
}
}

View File

@@ -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', () => {