Skip to content

Commit a0c5c22

Browse files
authored
make more space more embedded new file preview, add potential for a message but don't use it yet (microsoft#185962)
microsoft/vscode-copilot#350
1 parent 9b8451d commit a0c5c22

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/vs/workbench/contrib/inlineChat/browser/inlineChat.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,5 +304,8 @@
304304
}
305305

306306
.monaco-editor .inline-chat-newfile-widget .title {
307-
padding: 3px 0;
307+
display: flex;
308+
align-items: center;
309+
justify-content: space-between;
310+
padding: 3px 6px 3px 0;
308311
}

src/vs/workbench/contrib/inlineChat/browser/inlineChatLivePreviewWidget.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,14 @@ function isInlineDiffFriendly(mapping: LineRangeMapping): boolean {
359359
export class InlineChatFileCreatePreviewWidget extends ZoneWidget {
360360

361361
private readonly _elements = h('div.inline-chat-newfile-widget@domNode', [
362-
h('div.title.show-file-icons@title'),
362+
h('div.title@title', [
363+
h('span.name.show-file-icons@name'),
364+
h('span.detail@detail'),
365+
]),
363366
h('div.editor@editor'),
364367
]);
365368

366-
private readonly _title: ResourceLabel;
369+
private readonly _name: ResourceLabel;
367370
private readonly _previewEditor: ICodeEditor;
368371
private readonly _previewModel = new MutableDisposable();
369372
private _dim: Dimension | undefined;
@@ -379,7 +382,7 @@ export class InlineChatFileCreatePreviewWidget extends ZoneWidget {
379382
super(parentEditor, { showArrow: false, showFrame: false, isResizeable: false, isAccessible: true, showInHiddenAreas: true, ordinal: 10000 + 2 });
380383
super.create();
381384

382-
this._title = instaService.createInstance(ResourceLabel, this._elements.title, { supportIcons: true });
385+
this._name = instaService.createInstance(ResourceLabel, this._elements.name, { supportIcons: true });
383386

384387
const contributions = EditorExtensionsRegistry
385388
.getEditorContributions()
@@ -412,7 +415,7 @@ export class InlineChatFileCreatePreviewWidget extends ZoneWidget {
412415
}
413416

414417
override dispose(): void {
415-
this._title.dispose();
418+
this._name.dispose();
416419
this._previewEditor.dispose();
417420
this._previewModel.dispose();
418421
super.dispose();
@@ -428,15 +431,20 @@ export class InlineChatFileCreatePreviewWidget extends ZoneWidget {
428431

429432
showCreation(where: Range, uri: URI, edits: TextEdit[]): void {
430433

431-
this._title.element.setFile(uri, { fileKind: FileKind.FILE });
434+
this._name.element.setFile(uri, { fileKind: FileKind.FILE });
435+
432436
const langSelection = this._languageService.createByFilepathOrFirstLine(uri, undefined);
433437
const model = this._modelService.createModel('', langSelection, undefined, true);
434438
model.applyEdits(edits.map(edit => EditOperation.replace(Range.lift(edit.range), edit.text)));
435439
this._previewModel.value = model;
436440
this._previewEditor.setModel(model);
437441

438-
const lines = Math.min(7, model.getLineCount());
439-
const lineHeightPadding = (this.editor.getOption(EditorOption.lineHeight) / 12) /* padding-top/bottom*/;
442+
const lineHeight = this.editor.getOption(EditorOption.lineHeight);
443+
this._elements.title.style.height = `${lineHeight}px`;
444+
const maxLines = Math.max(4, Math.floor((this.editor.getLayoutInfo().height / lineHeight) / .33));
445+
446+
const lines = Math.min(maxLines, model.getLineCount());
447+
const lineHeightPadding = (lineHeight / 12) /* padding-top/bottom*/;
440448

441449

442450
super.show(where, lines + 1 + lineHeightPadding);

0 commit comments

Comments
 (0)