Skip to content

Commit cab1250

Browse files
authored
better handling of editor width in request bubbles (microsoft#249923)
1 parent e8abd52 commit cab1250

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

src/vs/workbench/contrib/chat/browser/chatContentParts/chatMarkdownContentPart.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ export class ChatMarkdownContentPart extends Disposable implements IChatContentP
248248
|| this.codeblocks.at(-1)?.isStreaming && this.codeblocks.at(-1)?.codemapperUri !== undefined && other.content.value.lastIndexOf('```') === this.markdown.content.value.lastIndexOf('```'));
249249
}
250250

251-
layout(width: number): void {
251+
layout(width: number, isRequest: boolean): void {
252252
this.allRefs.forEach((ref, index) => {
253253
if (ref.object instanceof CodeBlockPart) {
254-
ref.object.layout(width);
254+
ref.object.layout(width, isRequest);
255255
} else if (ref.object instanceof CollapsedCodeBlock) {
256256
const codeblockModel = this.codeblocks[index];
257257
if (codeblockModel.codemapperUri && ref.object.uri?.toString() !== codeblockModel.codemapperUri.toString()) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
11311131
const codeBlockStartIndex = this.getCodeBlockStartIndex(context);
11321132
const markdownPart = templateData.instantiationService.createInstance(ChatMarkdownContentPart, markdown, context, this._editorPool, fillInIncompleteTokens, codeBlockStartIndex, this.renderer, this._currentLayoutWidth, this.codeBlockModelCollection, {});
11331133
markdownPart.addDisposable(markdownPart.onDidChangeHeight(() => {
1134-
markdownPart.layout(this._currentLayoutWidth);
1134+
markdownPart.layout(this._currentLayoutWidth, isRequestVM(element));
11351135
this.updateItemHeight(templateData);
11361136
}));
11371137

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,3 @@
172172
.interactive-result-code-block.compare.no-diff .interactive-result-editor {
173173
display: none;
174174
}
175-
176-
.interactive-session .interactive-request .value .interactive-result-code-block .monaco-editor .overflow-guard,
177-
.interactive-session .interactive-request .value .monaco-editor {
178-
width: 100% !important;
179-
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import { getSimpleEditorOptions } from '../../codeEditor/browser/simpleEditorOpt
6464
import { IMarkdownVulnerability } from '../common/annotations.js';
6565
import { ChatContextKeys } from '../common/chatContextKeys.js';
6666
import { IChatResponseModel, IChatTextEditGroup } from '../common/chatModel.js';
67-
import { IChatResponseViewModel, isResponseVM } from '../common/chatViewModel.js';
67+
import { IChatResponseViewModel, isRequestVM, isResponseVM } from '../common/chatViewModel.js';
6868
import { ChatTreeItem } from './chat.js';
6969
import { IChatRendererDelegate } from './chatListRenderer.js';
7070
import { ChatEditorOptions } from './chatOptions.js';
@@ -370,7 +370,7 @@ export class CodeBlockPart extends Disposable {
370370
};
371371
}
372372

373-
layout(width: number): void {
373+
layout(width: number, isRequest?: boolean): void {
374374
const contentHeight = this.getContentHeight();
375375

376376
let height = contentHeight;
@@ -380,7 +380,7 @@ export class CodeBlockPart extends Disposable {
380380

381381
const editorBorder = 2;
382382
width = width - editorBorder - (this.currentCodeBlockData?.renderOptions?.reserveWidth ?? 0);
383-
this.editor.layout({ width, height });
383+
this.editor.layout({ width: isRequest ? width * 0.9 : width, height });
384384
this.updatePaddingForLayout();
385385
}
386386

@@ -402,7 +402,7 @@ export class CodeBlockPart extends Disposable {
402402
if (this.getEditorOptionsFromConfig().wordWrap === 'on') {
403403
// Initialize the editor with the new proper width so that getContentHeight
404404
// will be computed correctly in the next call to layout()
405-
this.layout(width);
405+
this.layout(width, isRequestVM(data.element));
406406
}
407407

408408
await this.updateEditor(data);
@@ -419,7 +419,7 @@ export class CodeBlockPart extends Disposable {
419419
ariaLabel: localize('chat.codeBlockLabel', "Code block {0}", data.codeBlockIndex + 1),
420420
});
421421
}
422-
this.layout(width);
422+
this.layout(width, isRequestVM(data.element));
423423
this.toolbar.setAriaLabel(localize('chat.codeBlockToolbarLabel', "Code block {0}", data.codeBlockIndex + 1));
424424
if (data.renderOptions?.hideToolbar) {
425425
dom.hide(this.toolbar.getElement());

0 commit comments

Comments
 (0)