Skip to content

Commit ee47c51

Browse files
authored
Add ResourceContextKey to chat codeblocks (microsoft#224662)
1 parent 51b031b commit ee47c51

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/vs/workbench/contrib/chat/browser/codeBlockPart.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import { getSimpleEditorOptions } from 'vs/workbench/contrib/codeEditor/browser/
6464
import { IMarkdownVulnerability } from '../common/annotations';
6565
import { ResourceLabel } from 'vs/workbench/browser/labels';
6666
import { FileKind } from 'vs/platform/files/common/files';
67+
import { ResourceContextKey } from 'vs/workbench/common/contextkeys';
6768

6869
const $ = dom.$;
6970

@@ -146,6 +147,8 @@ export class CodeBlockPart extends Disposable {
146147
private readonly disposableStore = this._register(new DisposableStore());
147148
private isDisposed = false;
148149

150+
private resourceContextKey: ResourceContextKey;
151+
149152
constructor(
150153
private readonly options: ChatEditorOptions,
151154
readonly menuId: MenuId,
@@ -160,6 +163,7 @@ export class CodeBlockPart extends Disposable {
160163
super();
161164
this.element = $('.interactive-result-code-block');
162165

166+
this.resourceContextKey = this._register(instantiationService.createInstance(ResourceContextKey));
163167
this.contextKeyService = this._register(contextKeyService.createScoped(this.element));
164168
const scopedInstantiationService = this._register(instantiationService.createChild(new ServiceCollection([IContextKeyService, this.contextKeyService])));
165169
const editorElement = dom.append(this.element, $('.interactive-result-editor'));
@@ -413,6 +417,7 @@ export class CodeBlockPart extends Disposable {
413417
element: data.element,
414418
languageId: textModel.getLanguageId()
415419
} satisfies ICodeBlockActionContext;
420+
this.resourceContextKey.set(textModel.uri);
416421
}
417422

418423
private getVulnerabilitiesLabel(): string {

0 commit comments

Comments
 (0)