Skip to content

Commit 034fd05

Browse files
authored
inline chat - workaround not being able to hide all lines of an editor (microsoft#187836)
1 parent d40162d commit 034fd05

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,15 +307,22 @@ export class InlineChatLivePreviewWidget extends ZoneWidget {
307307
}
308308

309309
private _hideEditorRanges(editor: ICodeEditor, lineRanges: LineRange[]): void {
310+
assertType(editor.hasModel());
311+
310312
lineRanges = lineRanges.filter(range => !range.isEmpty);
311313
if (lineRanges.length === 0) {
312314
// todo?
313315
this._logService.debug(`[IE] diff NOTHING to hide for ${editor.getId()} with ${String(editor.getModel()?.uri)}`);
314316
return;
315317
}
316-
const ranges = lineRanges.map(lineRangeAsRange);
317-
editor.setHiddenAreas(ranges, InlineChatLivePreviewWidget._hideId);
318-
this._logService.debug(`[IE] diff HIDING ${ranges} for ${editor.getId()} with ${String(editor.getModel()?.uri)}`);
318+
319+
let hiddenRanges = lineRanges.map(lineRangeAsRange);
320+
if (LineRange.fromRange(hiddenRanges.reduce(Range.plusRange)).equals(LineRange.ofLength(1, editor.getModel().getLineCount()))) {
321+
// TODO not every line can be hidden, keep the first line around
322+
hiddenRanges = [editor.getModel().getFullModelRange().delta(1)];
323+
}
324+
editor.setHiddenAreas(hiddenRanges, InlineChatLivePreviewWidget._hideId);
325+
this._logService.debug(`[IE] diff HIDING ${hiddenRanges} for ${editor.getId()} with ${String(editor.getModel()?.uri)}`);
319326
}
320327

321328
protected override revealRange(range: Range, isLastLine: boolean): void {

0 commit comments

Comments
 (0)