提交 310833d1 编写于 作者: A Alex Dima

IKeybindingService cannot give out Keybindings anymore

上级 5e72eec2
......@@ -592,4 +592,29 @@ export abstract class ResolvedKeybinding {
* This prints the binding in a format suitable for user settings.
*/
public abstract getUserSettingsLabel(): string;
/**
* Is the binding a chord?
*/
public abstract isChord(): boolean;
/**
* Does this binding use the ctrl modifier key.
* If it is a chord, it always returns false.
*/
public abstract hasCtrlModifier(): boolean;
/**
* Does this binding use the shift modifier key.
* If it is a chord, it always returns false.
*/
public abstract hasShiftModifier(): boolean;
/**
* Does this binding use the alt modifier key.
* If it is a chord, it always returns false.
*/
public abstract hasAltModifier(): boolean;
/**
* Does this binding use the meta modifier key.
* If it is a chord, it always returns false.
*/
public abstract hasMetaModifier(): boolean;
}
......@@ -252,7 +252,7 @@ export class QuickOpenWidget implements IModelProvider {
return false;
}
if (k.hasShift() && keyCode === KeyCode.Shift) {
if (k.hasShiftModifier() && keyCode === KeyCode.Shift) {
if (keyboardEvent.ctrlKey || keyboardEvent.altKey || keyboardEvent.metaKey) {
return false; // this is an optimistic check for the shift key being used to navigate back in quick open
}
......@@ -260,30 +260,16 @@ export class QuickOpenWidget implements IModelProvider {
return true;
}
if (k.hasAlt() && keyCode === KeyCode.Alt) {
if (k.hasAltModifier() && keyCode === KeyCode.Alt) {
return true;
}
// Mac is a bit special
if (platform.isMacintosh) {
if (k.hasCtrlCmd() && keyCode === KeyCode.Meta) {
return true;
}
if (k.hasWinCtrl() && keyCode === KeyCode.Ctrl) {
return true;
}
if (k.hasCtrlModifier() && keyCode === KeyCode.Ctrl) {
return true;
}
// Windows/Linux are not :)
else {
if (k.hasCtrlCmd() && keyCode === KeyCode.Ctrl) {
return true;
}
if (k.hasWinCtrl() && keyCode === KeyCode.Meta) {
return true;
}
if (k.hasMetaModifier() && keyCode === KeyCode.Meta) {
return true;
}
return false;
......
......@@ -4,10 +4,10 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import { Keybinding } from 'vs/base/common/keyCodes';
import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
export interface IQuickNavigateConfiguration {
keybindings: Keybinding[];
keybindings: ResolvedKeybinding[];
}
export interface IAutoFocus {
......
......@@ -109,6 +109,46 @@ export class USLayoutResolvedKeybinding extends ResolvedKeybinding {
let result = UserSettingsLabelProvider.toLabel2(firstPart, chordPart, this._os);
return result.toLowerCase();
}
public isChord(): boolean {
return this._actual.isChord();
}
public hasCtrlModifier(): boolean {
if (this._actual.isChord()) {
return false;
}
if (this._os === OperatingSystem.Macintosh) {
return this._actual.hasWinCtrl();
} else {
return this._actual.hasCtrlCmd();
}
}
public hasShiftModifier(): boolean {
if (this._actual.isChord()) {
return false;
}
return this._actual.hasShift();
}
public hasAltModifier(): boolean {
if (this._actual.isChord()) {
return false;
}
return this._actual.hasAlt();
}
public hasMetaModifier(): boolean {
if (this._actual.isChord()) {
return false;
}
if (this._os === OperatingSystem.Macintosh) {
return this._actual.hasCtrlCmd();
} else {
return this._actual.hasWinCtrl();
}
}
}
interface CurrentChord {
......@@ -179,8 +219,8 @@ export abstract class AbstractKeybindingService implements IKeybindingService {
return 0;
}
public lookupKeybindings(commandId: string): Keybinding[] {
return this._getResolver().lookupKeybindings(commandId).map(item => item.keybinding);
public lookupKeybindings(commandId: string): ResolvedKeybinding[] {
return this._getResolver().lookupKeybindings(commandId).map(item => this._createResolvedKeybinding(item.keybinding));
}
public lookupKeybinding(commandId: string): ResolvedKeybinding {
......
......@@ -74,9 +74,10 @@ export interface IKeybindingService {
getKeybindings(): IKeybindingItem2[];
/**
* @deprecated
* Look up keybindings for a command.
* Use `lookupKeybinding` if you are interested in the preferred keybinding.
*/
lookupKeybindings(commandId: string): Keybinding[];
lookupKeybindings(commandId: string): ResolvedKeybinding[];
/**
* Look up the preferred (last defined) keybinding for a command.
......
......@@ -80,7 +80,7 @@ export class MockKeybindingService2 implements IKeybindingService {
return new USLayoutResolvedKeybinding(keybinding, OS);
}
public lookupKeybindings(commandId: string): Keybinding[] {
public lookupKeybindings(commandId: string): ResolvedKeybinding[] {
return [];
}
......
......@@ -198,7 +198,7 @@ export abstract class EditorGroupPicker extends BaseEditorPicker {
return super.getAutoFocus(searchValue);
}
const isShiftNavigate = (quickNavigateConfiguration && quickNavigateConfiguration.keybindings.some(k => !k.isChord() && k.hasShift()));
const isShiftNavigate = (quickNavigateConfiguration && quickNavigateConfiguration.keybindings.some(k => !k.isChord() && k.hasShiftModifier()));
if (isShiftNavigate) {
return {
autoFocusLastEntry: true
......
......@@ -117,6 +117,26 @@ export class NativeResolvedKeybinding extends ResolvedKeybinding {
throw new Error('TODO!');
// return KeybindingIO.writeKeybinding(this._actual, OS);
}
public isChord(): boolean {
throw new Error('TODO!');
}
public hasCtrlModifier(): boolean {
throw new Error('TODO!');
}
public hasShiftModifier(): boolean {
throw new Error('TODO!');
}
public hasAltModifier(): boolean {
throw new Error('TODO!');
}
public hasMetaModifier(): boolean {
throw new Error('TODO!');
}
}
interface IHardwareCodeMapping {
......
......@@ -172,6 +172,46 @@ export class FancyResolvedKeybinding extends ResolvedKeybinding {
public getUserSettingsLabel(): string {
return KeybindingIO.writeKeybinding(this._actual, OS);
}
public isChord(): boolean {
return this._actual.isChord();
}
public hasCtrlModifier(): boolean {
if (this._actual.isChord()) {
return false;
}
if (OS === OperatingSystem.Macintosh) {
return this._actual.hasWinCtrl();
} else {
return this._actual.hasCtrlCmd();
}
}
public hasShiftModifier(): boolean {
if (this._actual.isChord()) {
return false;
}
return this._actual.hasShift();
}
public hasAltModifier(): boolean {
if (this._actual.isChord()) {
return false;
}
return this._actual.hasAlt();
}
public hasMetaModifier(): boolean {
if (this._actual.isChord()) {
return false;
}
if (OS === OperatingSystem.Macintosh) {
return this._actual.hasCtrlCmd();
} else {
return this._actual.hasWinCtrl();
}
}
}
export class WorkbenchKeybindingService extends AbstractKeybindingService {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册