提交 5b25934b 编写于 作者: M Matt Bierner

Disable some commands while in the walkthrough

上级 5db9993b
...@@ -3129,6 +3129,10 @@ export namespace ModeContextKeys { ...@@ -3129,6 +3129,10 @@ export namespace ModeContextKeys {
* @internal * @internal
*/ */
export const hasSignatureHelpProvider = new RawContextKey<boolean>('editorHasSignatureHelpProvider', undefined); export const hasSignatureHelpProvider = new RawContextKey<boolean>('editorHasSignatureHelpProvider', undefined);
/**
* @internal
*/
export const isInWalkThrough = new RawContextKey<boolean>('isInWalkThrough', undefined);
} }
......
...@@ -28,6 +28,7 @@ export class EditorModeContext { ...@@ -28,6 +28,7 @@ export class EditorModeContext {
private _hasDocumentFormattingProvider: IContextKey<boolean>; private _hasDocumentFormattingProvider: IContextKey<boolean>;
private _hasDocumentSelectionFormattingProvider: IContextKey<boolean>; private _hasDocumentSelectionFormattingProvider: IContextKey<boolean>;
private _hasSignatureHelpProvider: IContextKey<boolean>; private _hasSignatureHelpProvider: IContextKey<boolean>;
private _isInWalkThrough: IContextKey<boolean>;
constructor( constructor(
editor: ICommonCodeEditor, editor: ICommonCodeEditor,
...@@ -49,6 +50,7 @@ export class EditorModeContext { ...@@ -49,6 +50,7 @@ export class EditorModeContext {
this._hasDocumentFormattingProvider = ModeContextKeys.hasDocumentFormattingProvider.bindTo(contextKeyService); this._hasDocumentFormattingProvider = ModeContextKeys.hasDocumentFormattingProvider.bindTo(contextKeyService);
this._hasDocumentSelectionFormattingProvider = ModeContextKeys.hasDocumentSelectionFormattingProvider.bindTo(contextKeyService); this._hasDocumentSelectionFormattingProvider = ModeContextKeys.hasDocumentSelectionFormattingProvider.bindTo(contextKeyService);
this._hasSignatureHelpProvider = ModeContextKeys.hasSignatureHelpProvider.bindTo(contextKeyService); this._hasSignatureHelpProvider = ModeContextKeys.hasSignatureHelpProvider.bindTo(contextKeyService);
this._isInWalkThrough = ModeContextKeys.isInWalkThrough.bindTo(contextKeyService);
// update when model/mode changes // update when model/mode changes
this._disposables.push(editor.onDidChangeModel(() => this._update())); this._disposables.push(editor.onDidChangeModel(() => this._update()));
...@@ -91,6 +93,7 @@ export class EditorModeContext { ...@@ -91,6 +93,7 @@ export class EditorModeContext {
this._hasDocumentFormattingProvider.reset(); this._hasDocumentFormattingProvider.reset();
this._hasDocumentSelectionFormattingProvider.reset(); this._hasDocumentSelectionFormattingProvider.reset();
this._hasSignatureHelpProvider.reset(); this._hasSignatureHelpProvider.reset();
this._isInWalkThrough.reset();
} }
private _update() { private _update() {
...@@ -113,5 +116,6 @@ export class EditorModeContext { ...@@ -113,5 +116,6 @@ export class EditorModeContext {
this._hasSignatureHelpProvider.set(modes.SignatureHelpProviderRegistry.has(model)); this._hasSignatureHelpProvider.set(modes.SignatureHelpProviderRegistry.has(model));
this._hasDocumentFormattingProvider.set(modes.DocumentFormattingEditProviderRegistry.has(model) || modes.DocumentRangeFormattingEditProviderRegistry.has(model)); this._hasDocumentFormattingProvider.set(modes.DocumentFormattingEditProviderRegistry.has(model) || modes.DocumentRangeFormattingEditProviderRegistry.has(model));
this._hasDocumentSelectionFormattingProvider.set(modes.DocumentRangeFormattingEditProviderRegistry.has(model)); this._hasDocumentSelectionFormattingProvider.set(modes.DocumentRangeFormattingEditProviderRegistry.has(model));
this._isInWalkThrough.set(model.uri.scheme === 'walkThroughSnippet');
} }
} }
...@@ -169,7 +169,9 @@ export class GoToDefinitionAction extends DefinitionAction { ...@@ -169,7 +169,9 @@ export class GoToDefinitionAction extends DefinitionAction {
id: GoToDefinitionAction.ID, id: GoToDefinitionAction.ID,
label: nls.localize('actions.goToDecl.label', "Go to Definition"), label: nls.localize('actions.goToDecl.label', "Go to Definition"),
alias: 'Go to Definition', alias: 'Go to Definition',
precondition: ModeContextKeys.hasDefinitionProvider, precondition: ContextKeyExpr.and(
ModeContextKeys.hasDefinitionProvider,
ModeContextKeys.isInWalkThrough.toNegated()),
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.TextFocus, kbExpr: EditorContextKeys.TextFocus,
primary: goToDeclarationKb primary: goToDeclarationKb
...@@ -192,7 +194,9 @@ export class OpenDefinitionToSideAction extends DefinitionAction { ...@@ -192,7 +194,9 @@ export class OpenDefinitionToSideAction extends DefinitionAction {
id: OpenDefinitionToSideAction.ID, id: OpenDefinitionToSideAction.ID,
label: nls.localize('actions.goToDeclToSide.label', "Open Definition to the Side"), label: nls.localize('actions.goToDeclToSide.label', "Open Definition to the Side"),
alias: 'Open Definition to the Side', alias: 'Open Definition to the Side',
precondition: ModeContextKeys.hasDefinitionProvider, precondition: ContextKeyExpr.and(
ModeContextKeys.hasDefinitionProvider,
ModeContextKeys.isInWalkThrough.toNegated()),
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.TextFocus, kbExpr: EditorContextKeys.TextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, goToDeclarationKb) primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, goToDeclarationKb)
...@@ -208,7 +212,10 @@ export class PeekDefinitionAction extends DefinitionAction { ...@@ -208,7 +212,10 @@ export class PeekDefinitionAction extends DefinitionAction {
id: 'editor.action.previewDeclaration', id: 'editor.action.previewDeclaration',
label: nls.localize('actions.previewDecl.label', "Peek Definition"), label: nls.localize('actions.previewDecl.label', "Peek Definition"),
alias: 'Peek Definition', alias: 'Peek Definition',
precondition: ContextKeyExpr.and(ModeContextKeys.hasDefinitionProvider, PeekContext.notInPeekEditor), precondition: ContextKeyExpr.and(
ModeContextKeys.hasDefinitionProvider,
PeekContext.notInPeekEditor,
ModeContextKeys.isInWalkThrough.toNegated()),
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.TextFocus, kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Alt | KeyCode.F12, primary: KeyMod.Alt | KeyCode.F12,
...@@ -233,7 +240,9 @@ export class GoToImplementationAction extends DefinitionAction { ...@@ -233,7 +240,9 @@ export class GoToImplementationAction extends DefinitionAction {
id: GoToImplementationAction.ID, id: GoToImplementationAction.ID,
label: nls.localize('actions.goToImplementation.label', "Go to Implementation"), label: nls.localize('actions.goToImplementation.label', "Go to Implementation"),
alias: 'Go to Implementation', alias: 'Go to Implementation',
precondition: ModeContextKeys.hasTypeDefinitionProvider, precondition: ContextKeyExpr.and(
ModeContextKeys.hasTypeDefinitionProvider,
ModeContextKeys.isInWalkThrough.toNegated()),
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.TextFocus, kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyCode.F12 primary: KeyMod.CtrlCmd | KeyCode.F12
...@@ -260,7 +269,9 @@ export class PeekImplementationAction extends DefinitionAction { ...@@ -260,7 +269,9 @@ export class PeekImplementationAction extends DefinitionAction {
id: PeekImplementationAction.ID, id: PeekImplementationAction.ID,
label: nls.localize('actions.peekImplementation.label', "Peek Implementation"), label: nls.localize('actions.peekImplementation.label', "Peek Implementation"),
alias: 'Peek Implementation', alias: 'Peek Implementation',
precondition: ModeContextKeys.hasTypeDefinitionProvider, precondition: ContextKeyExpr.and(
ModeContextKeys.hasTypeDefinitionProvider,
ModeContextKeys.isInWalkThrough.toNegated()),
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.TextFocus, kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F12 primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F12
......
...@@ -63,7 +63,10 @@ export class ReferenceAction extends EditorAction { ...@@ -63,7 +63,10 @@ export class ReferenceAction extends EditorAction {
id: 'editor.action.referenceSearch.trigger', id: 'editor.action.referenceSearch.trigger',
label: nls.localize('references.action.label', "Find All References"), label: nls.localize('references.action.label', "Find All References"),
alias: 'Find All References', alias: 'Find All References',
precondition: ContextKeyExpr.and(ModeContextKeys.hasReferenceProvider, PeekContext.notInPeekEditor), precondition: ContextKeyExpr.and(
ModeContextKeys.hasReferenceProvider,
PeekContext.notInPeekEditor,
ModeContextKeys.isInWalkThrough.toNegated()),
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.TextFocus, kbExpr: EditorContextKeys.TextFocus,
primary: KeyMod.Shift | KeyCode.F12 primary: KeyMod.Shift | KeyCode.F12
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册