Skip to content

Commit 533da38

Browse files
authored
Use InEmbeddedEditor context for chat code blocks (microsoft#204641)
This als: - Renames the variable to match the context key name - Uses this context key to disable peek call hierarchy - Enable the normal go to def commands in these contexts (not the peek versions)
1 parent 348e88d commit 533da38

File tree

4 files changed

+19
-24
lines changed

4 files changed

+19
-24
lines changed

src/vs/editor/browser/widget/codeEditorWidget.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,7 @@ export class EditorModeContext extends Disposable {
20952095
private readonly _hasMultipleDocumentSelectionFormattingProvider: IContextKey<boolean>;
20962096
private readonly _hasSignatureHelpProvider: IContextKey<boolean>;
20972097
private readonly _hasInlayHintsProvider: IContextKey<boolean>;
2098-
private readonly _isInWalkThrough: IContextKey<boolean>;
2098+
private readonly _isInEmbeddedEditor: IContextKey<boolean>;
20992099

21002100
constructor(
21012101
private readonly _editor: CodeEditorWidget,
@@ -2123,7 +2123,7 @@ export class EditorModeContext extends Disposable {
21232123
this._hasDocumentSelectionFormattingProvider = EditorContextKeys.hasDocumentSelectionFormattingProvider.bindTo(_contextKeyService);
21242124
this._hasMultipleDocumentFormattingProvider = EditorContextKeys.hasMultipleDocumentFormattingProvider.bindTo(_contextKeyService);
21252125
this._hasMultipleDocumentSelectionFormattingProvider = EditorContextKeys.hasMultipleDocumentSelectionFormattingProvider.bindTo(_contextKeyService);
2126-
this._isInWalkThrough = EditorContextKeys.isInWalkThroughSnippet.bindTo(_contextKeyService);
2126+
this._isInEmbeddedEditor = EditorContextKeys.isInEmbeddedEditor.bindTo(_contextKeyService);
21272127

21282128
const update = () => this._update();
21292129

@@ -2174,7 +2174,7 @@ export class EditorModeContext extends Disposable {
21742174
this._hasDocumentFormattingProvider.reset();
21752175
this._hasDocumentSelectionFormattingProvider.reset();
21762176
this._hasSignatureHelpProvider.reset();
2177-
this._isInWalkThrough.reset();
2177+
this._isInEmbeddedEditor.reset();
21782178
});
21792179
}
21802180

@@ -2204,7 +2204,7 @@ export class EditorModeContext extends Disposable {
22042204
this._hasDocumentSelectionFormattingProvider.set(this._languageFeaturesService.documentRangeFormattingEditProvider.has(model));
22052205
this._hasMultipleDocumentFormattingProvider.set(this._languageFeaturesService.documentFormattingEditProvider.all(model).length + this._languageFeaturesService.documentRangeFormattingEditProvider.all(model).length > 1);
22062206
this._hasMultipleDocumentSelectionFormattingProvider.set(this._languageFeaturesService.documentRangeFormattingEditProvider.all(model).length > 1);
2207-
this._isInWalkThrough.set(model.uri.scheme === Schemas.walkThroughSnippet);
2207+
this._isInEmbeddedEditor.set(model.uri.scheme === Schemas.walkThroughSnippet || model.uri.scheme === Schemas.vscodeChatCodeBlock);
22082208
});
22092209
}
22102210
}

src/vs/editor/common/editorContextKeys.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export namespace EditorContextKeys {
4242
export const hasSingleSelection = hasMultipleSelections.toNegated();
4343
export const tabMovesFocus = new RawContextKey<boolean>('editorTabMovesFocus', false, nls.localize('editorTabMovesFocus', "Whether `Tab` will move focus out of the editor"));
4444
export const tabDoesNotMoveFocus = tabMovesFocus.toNegated();
45-
export const isInWalkThroughSnippet = new RawContextKey<boolean>('isInEmbeddedEditor', false, true);
45+
export const isInEmbeddedEditor = new RawContextKey<boolean>('isInEmbeddedEditor', false, true);
4646
export const canUndo = new RawContextKey<boolean>('canUndo', false, true);
4747
export const canRedo = new RawContextKey<boolean>('canRedo', false, true);
4848

src/vs/editor/contrib/gotoSymbol/browser/goToCommands.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,7 @@ registerAction2(class GoToDefinitionAction extends DefinitionAction {
286286
...nls.localize2('actions.goToDecl.label', "Go to Definition"),
287287
mnemonicTitle: nls.localize({ key: 'miGotoDefinition', comment: ['&& denotes a mnemonic'] }, "Go to &&Definition"),
288288
},
289-
precondition: ContextKeyExpr.and(
290-
EditorContextKeys.hasDefinitionProvider,
291-
EditorContextKeys.isInWalkThroughSnippet.toNegated()),
289+
precondition: EditorContextKeys.hasDefinitionProvider,
292290
keybinding: [{
293291
when: EditorContextKeys.editorTextFocus,
294292
primary: KeyCode.F12,
@@ -327,7 +325,7 @@ registerAction2(class OpenDefinitionToSideAction extends DefinitionAction {
327325
title: nls.localize2('actions.goToDeclToSide.label', "Open Definition to the Side"),
328326
precondition: ContextKeyExpr.and(
329327
EditorContextKeys.hasDefinitionProvider,
330-
EditorContextKeys.isInWalkThroughSnippet.toNegated()),
328+
EditorContextKeys.isInEmbeddedEditor.toNegated()),
331329
keybinding: [{
332330
when: EditorContextKeys.editorTextFocus,
333331
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyCode.F12),
@@ -357,7 +355,7 @@ registerAction2(class PeekDefinitionAction extends DefinitionAction {
357355
precondition: ContextKeyExpr.and(
358356
EditorContextKeys.hasDefinitionProvider,
359357
PeekContext.notInPeekEditor,
360-
EditorContextKeys.isInWalkThroughSnippet.toNegated()
358+
EditorContextKeys.isInEmbeddedEditor.toNegated()
361359
),
362360
keybinding: {
363361
when: EditorContextKeys.editorTextFocus,
@@ -417,7 +415,7 @@ registerAction2(class GoToDeclarationAction extends DeclarationAction {
417415
},
418416
precondition: ContextKeyExpr.and(
419417
EditorContextKeys.hasDeclarationProvider,
420-
EditorContextKeys.isInWalkThroughSnippet.toNegated()
418+
EditorContextKeys.isInEmbeddedEditor.toNegated()
421419
),
422420
menu: [{
423421
id: MenuId.EditorContext,
@@ -451,7 +449,7 @@ registerAction2(class PeekDeclarationAction extends DeclarationAction {
451449
precondition: ContextKeyExpr.and(
452450
EditorContextKeys.hasDeclarationProvider,
453451
PeekContext.notInPeekEditor,
454-
EditorContextKeys.isInWalkThroughSnippet.toNegated()
452+
EditorContextKeys.isInEmbeddedEditor.toNegated()
455453
),
456454
menu: {
457455
id: MenuId.EditorContextPeek,
@@ -502,9 +500,7 @@ registerAction2(class GoToTypeDefinitionAction extends TypeDefinitionAction {
502500
...nls.localize2('actions.goToTypeDefinition.label', "Go to Type Definition"),
503501
mnemonicTitle: nls.localize({ key: 'miGotoTypeDefinition', comment: ['&& denotes a mnemonic'] }, "Go to &&Type Definition"),
504502
},
505-
precondition: ContextKeyExpr.and(
506-
EditorContextKeys.hasTypeDefinitionProvider,
507-
EditorContextKeys.isInWalkThroughSnippet.toNegated()),
503+
precondition: EditorContextKeys.hasTypeDefinitionProvider,
508504
keybinding: {
509505
when: EditorContextKeys.editorTextFocus,
510506
primary: 0,
@@ -539,7 +535,7 @@ registerAction2(class PeekTypeDefinitionAction extends TypeDefinitionAction {
539535
precondition: ContextKeyExpr.and(
540536
EditorContextKeys.hasTypeDefinitionProvider,
541537
PeekContext.notInPeekEditor,
542-
EditorContextKeys.isInWalkThroughSnippet.toNegated()
538+
EditorContextKeys.isInEmbeddedEditor.toNegated()
543539
),
544540
menu: {
545541
id: MenuId.EditorContextPeek,
@@ -590,9 +586,7 @@ registerAction2(class GoToImplementationAction extends ImplementationAction {
590586
...nls.localize2('actions.goToImplementation.label', "Go to Implementations"),
591587
mnemonicTitle: nls.localize({ key: 'miGotoImplementation', comment: ['&& denotes a mnemonic'] }, "Go to &&Implementations"),
592588
},
593-
precondition: ContextKeyExpr.and(
594-
EditorContextKeys.hasImplementationProvider,
595-
EditorContextKeys.isInWalkThroughSnippet.toNegated()),
589+
precondition: EditorContextKeys.hasImplementationProvider,
596590
keybinding: {
597591
when: EditorContextKeys.editorTextFocus,
598592
primary: KeyMod.CtrlCmd | KeyCode.F12,
@@ -627,7 +621,7 @@ registerAction2(class PeekImplementationAction extends ImplementationAction {
627621
precondition: ContextKeyExpr.and(
628622
EditorContextKeys.hasImplementationProvider,
629623
PeekContext.notInPeekEditor,
630-
EditorContextKeys.isInWalkThroughSnippet.toNegated()
624+
EditorContextKeys.isInEmbeddedEditor.toNegated()
631625
),
632626
keybinding: {
633627
when: EditorContextKeys.editorTextFocus,
@@ -680,7 +674,7 @@ registerAction2(class GoToReferencesAction extends ReferencesAction {
680674
precondition: ContextKeyExpr.and(
681675
EditorContextKeys.hasReferenceProvider,
682676
PeekContext.notInPeekEditor,
683-
EditorContextKeys.isInWalkThroughSnippet.toNegated()
677+
EditorContextKeys.isInEmbeddedEditor.toNegated()
684678
),
685679
keybinding: {
686680
when: EditorContextKeys.editorTextFocus,
@@ -718,7 +712,7 @@ registerAction2(class PeekReferencesAction extends ReferencesAction {
718712
precondition: ContextKeyExpr.and(
719713
EditorContextKeys.hasReferenceProvider,
720714
PeekContext.notInPeekEditor,
721-
EditorContextKeys.isInWalkThroughSnippet.toNegated()
715+
EditorContextKeys.isInEmbeddedEditor.toNegated()
722716
),
723717
menu: {
724718
id: MenuId.EditorContextPeek,
@@ -750,7 +744,7 @@ class GenericGoToLocationAction extends SymbolNavigationAction {
750744
title: nls.localize2('label.generic', "Go to Any Symbol"),
751745
precondition: ContextKeyExpr.and(
752746
PeekContext.notInPeekEditor,
753-
EditorContextKeys.isInWalkThroughSnippet.toNegated()
747+
EditorContextKeys.isInEmbeddedEditor.toNegated()
754748
),
755749
});
756750
}

src/vs/workbench/contrib/callHierarchy/browser/callHierarchy.contribution.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ registerAction2(class PeekCallHierarchyAction extends EditorAction2 {
186186
order: 1000,
187187
when: ContextKeyExpr.and(
188188
_ctxHasCallHierarchyProvider,
189-
PeekContext.notInPeekEditor
189+
PeekContext.notInPeekEditor,
190+
EditorContextKeys.isInEmbeddedEditor.toNegated(),
190191
),
191192
},
192193
keybinding: {

0 commit comments

Comments
 (0)