Skip to content

Commit

Permalink
Add ResourceContextKey to chat codeblocks (microsoft#224662)
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens authored Aug 3, 2024
1 parent 51b031b commit ee47c51
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/vs/workbench/contrib/chat/browser/codeBlockPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.$;

Expand Down Expand Up @@ -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,
Expand All @@ -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'));
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ee47c51

Please sign in to comment.