提交 5006661c 编写于 作者: A Alex Dima

Contain bubbling information in keybindingResolver

上级 b7a3a1c4
......@@ -95,10 +95,6 @@ export abstract class AbstractKeybindingService implements IKeybindingService {
return this._createResolvedKeybinding(keybinding);
}
protected getLabelFor(keybinding: Keybinding): string {
return KeybindingLabels._toUSLabel(keybinding);
}
public getDefaultKeybindings(): string {
return this._getResolver().getDefaultKeybindings() + '\n\n' + this._getAllCommandsAsComment();
}
......@@ -166,7 +162,7 @@ export abstract class AbstractKeybindingService implements IKeybindingService {
shouldPreventDefault = true;
this._currentChord = resolveResult.enterChord;
if (this._statusService) {
let firstPartLabel = this.getLabelFor(this._currentChord);
let firstPartLabel = this._createResolvedKeybinding(this._currentChord).getLabel();
this._currentChordStatusMessage = this._statusService.setStatusMessage(nls.localize('first.chord', "({0}) was pressed. Waiting for second key of chord...", firstPartLabel));
}
return shouldPreventDefault;
......@@ -174,8 +170,8 @@ export abstract class AbstractKeybindingService implements IKeybindingService {
if (this._statusService && this._currentChord) {
if (!resolveResult || !resolveResult.commandId) {
let firstPartLabel = this.getLabelFor(this._currentChord);
let chordPartLabel = this.getLabelFor(keybinding);
let firstPartLabel = this._createResolvedKeybinding(this._currentChord).getLabel();
let chordPartLabel = this._createResolvedKeybinding(keybinding).getLabel();
this._statusService.setStatusMessage(nls.localize('missing.chord', "The key combination ({0}, {1}) is not a command.", firstPartLabel, chordPartLabel), 10 * 1000 /* 10s */);
shouldPreventDefault = true;
}
......@@ -187,11 +183,10 @@ export abstract class AbstractKeybindingService implements IKeybindingService {
this._currentChord = null;
if (resolveResult && resolveResult.commandId) {
if (!/^\^/.test(resolveResult.commandId)) {
if (!resolveResult.bubble) {
shouldPreventDefault = true;
}
let commandId = resolveResult.commandId.replace(/^\^/, '');
this._commandService.executeCommand(commandId, resolveResult.commandArgs || {}).done(undefined, err => {
this._commandService.executeCommand(resolveResult.commandId, resolveResult.commandArgs || {}).done(undefined, err => {
this._messageService.show(Severity.Warning, err);
});
}
......
......@@ -9,11 +9,13 @@ import { ISimplifiedPlatform, KeybindingLabels } from 'vs/platform/keybinding/co
import * as platform from 'vs/base/common/platform';
import { IKeybindingItem, IUserFriendlyKeybinding } from 'vs/platform/keybinding/common/keybinding';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { CharCode } from "vs/base/common/charCode";
export interface IResolveResult {
enterChord: SimpleKeybinding;
commandId: string;
commandArgs: any;
bubble: boolean;
}
export interface IBoundCommands {
......@@ -346,14 +348,19 @@ export class KeybindingResolver {
return {
enterChord: keypress,
commandId: null,
commandArgs: null
commandArgs: null,
bubble: false
};
}
let bubble = (result.commandId ? result.commandId.charCodeAt(0) === CharCode.Caret : false);
let commandId = (result.commandId ? result.commandId.replace(/^\^/, '') : result.commandId);
return {
enterChord: null,
commandId: result.commandId,
commandArgs: result.commandArgs
commandId: commandId,
commandArgs: result.commandArgs,
bubble: bubble
};
}
......
......@@ -261,10 +261,6 @@ export class WorkbenchKeybindingService extends AbstractKeybindingService {
return new FancyResolvedKeybinding(kb);
}
protected getLabelFor(keybinding: Keybinding): string {
return KeybindingLabels.toCustomLabel(keybinding, getNativeLabelProvider());
}
private _handleKeybindingsExtensionPointUser(isBuiltin: boolean, keybindings: ContributedKeyBinding | ContributedKeyBinding[], collector: ExtensionMessageCollector): boolean {
if (isContributedKeyBindingsArray(keybindings)) {
let commandAdded = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册