From 42f1c65b6076befb3cdb61375107d2eca24c7ac1 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Fri, 2 Aug 2024 17:21:40 -0700 Subject: [PATCH] Add ResourceContextKey to chat codeblocks --- src/vs/workbench/contrib/chat/browser/codeBlockPart.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vs/workbench/contrib/chat/browser/codeBlockPart.ts b/src/vs/workbench/contrib/chat/browser/codeBlockPart.ts index d79ce9461636d..bc5cea824fab9 100644 --- a/src/vs/workbench/contrib/chat/browser/codeBlockPart.ts +++ b/src/vs/workbench/contrib/chat/browser/codeBlockPart.ts @@ -64,6 +64,7 @@ import { getSimpleEditorOptions } from 'vs/workbench/contrib/codeEditor/browser/ import { IMarkdownVulnerability } from '../common/annotations'; import { ResourceLabel } from 'vs/workbench/browser/labels'; import { FileKind } from 'vs/platform/files/common/files'; +import { ResourceContextKey } from 'vs/workbench/common/contextkeys'; const $ = dom.$; @@ -146,6 +147,8 @@ export class CodeBlockPart extends Disposable { private readonly disposableStore = this._register(new DisposableStore()); private isDisposed = false; + private resourceContextKey: ResourceContextKey; + constructor( private readonly options: ChatEditorOptions, readonly menuId: MenuId, @@ -160,6 +163,7 @@ export class CodeBlockPart extends Disposable { super(); this.element = $('.interactive-result-code-block'); + this.resourceContextKey = this._register(instantiationService.createInstance(ResourceContextKey)); this.contextKeyService = this._register(contextKeyService.createScoped(this.element)); const scopedInstantiationService = this._register(instantiationService.createChild(new ServiceCollection([IContextKeyService, this.contextKeyService]))); const editorElement = dom.append(this.element, $('.interactive-result-editor')); @@ -413,6 +417,7 @@ export class CodeBlockPart extends Disposable { element: data.element, languageId: textModel.getLanguageId() } satisfies ICodeBlockActionContext; + this.resourceContextKey.set(textModel.uri); } private getVulnerabilitiesLabel(): string {