diff --git a/src/vs/workbench/contrib/chat/browser/codeBlockPart.ts b/src/vs/workbench/contrib/chat/browser/codeBlockPart.ts index b397943928e..6e7f34f5ad6 100644 --- a/src/vs/workbench/contrib/chat/browser/codeBlockPart.ts +++ b/src/vs/workbench/contrib/chat/browser/codeBlockPart.ts @@ -13,7 +13,7 @@ import { Disposable, IReference, MutableDisposable } from 'vs/base/common/lifecy import { URI, UriComponents } from 'vs/base/common/uri'; import { EditorExtensionsRegistry } from 'vs/editor/browser/editorExtensions'; import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget'; -import { EDITOR_FONT_DEFAULTS, IEditorOptions } from 'vs/editor/common/config/editorOptions'; +import { EDITOR_FONT_DEFAULTS, EditorOption, IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { IRange, Range } from 'vs/editor/common/core/range'; import { ScrollType } from 'vs/editor/common/editorCommon'; import { ILanguageService } from 'vs/editor/common/languages/language'; @@ -256,13 +256,16 @@ abstract class BaseCodeBlockPart extends Disposable } layout(width: number): void { - const realContentHeight = this.editor.getContentHeight(); + const contentHeight = this.getContentHeight(); const editorBorder = 2; - // TODO: Min added for testing. Compute proper height based on range - this.editor.layout({ width: width - editorBorder, height: Math.min(realContentHeight, 100) }); + this.editor.layout({ width: width - editorBorder, height: contentHeight }); this.updatePaddingForLayout(); } + protected getContentHeight() { + return this.editor.getContentHeight(); + } + async render(data: Data, width: number) { if (data.parentContextKeyService) { this.contextKeyService.updateParent(data.parentContextKeyService); @@ -323,8 +326,8 @@ export class SimpleCodeBlockPart extends BaseCodeBlockPart buttonSeparator: undefined, supportIcons: true }); - - this.textModel = this._register(this.modelService.createModel('', null, undefined, true)); + const x = URI.from({ scheme: 'ai', path: `chat-code-block-${Date.now()}.txt` }); + this.textModel = this._register(this.modelService.createModel('', null, x, true)); this.editor.setModel(this.textModel); this.vulnsListElement = dom.append(vulnsContainer, $('ul.interactive-result-vulns-list')); @@ -457,6 +460,15 @@ export class LocalFileCodeBlockPart extends BaseCodeBlockPart): CodeEditorWidget { return this._register(instantiationService.createInstance(CodeEditorWidget, parent, { ...options,