From a4cf93cffff765c96e47ed5ebf41cc3e899ade77 Mon Sep 17 00:00:00 2001 From: Johannes Date: Mon, 16 Oct 2023 16:41:39 +0200 Subject: [PATCH] don't show background decoration when just whitespace fixes https://github.com/microsoft/vscode-copilot/issues/1958 --- .../inlineChat/browser/inlineChatController.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts b/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts index 5083e62ac4b..a5a31233e66 100644 --- a/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts +++ b/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts @@ -40,6 +40,7 @@ import { generateUuid } from 'vs/base/common/uuid'; import { TextEdit } from 'vs/editor/common/languages'; import { ISelection, Selection } from 'vs/editor/common/core/selection'; import { onUnexpectedError } from 'vs/base/common/errors'; +import { IModelDeltaDecoration } from 'vs/editor/common/model'; export const enum State { CREATE_SESSION = 'CREATE_SESSION', @@ -336,10 +337,16 @@ export class InlineChatController implements IEditorContribution { const wholeRangeDecoration = this._editor.createDecorationsCollection(); const updateWholeRangeDecoration = () => { - wholeRangeDecoration.set([{ - range: this._activeSession!.wholeRange.value, - options: InlineChatController._decoBlock - }]); + + const range = this._activeSession!.wholeRange.value; + const decorations: IModelDeltaDecoration[] = []; + if (!range.isEmpty()) { + decorations.push({ + range, + options: InlineChatController._decoBlock + }); + } + wholeRangeDecoration.set(decorations); }; this._sessionStore.add(toDisposable(() => wholeRangeDecoration.clear())); this._sessionStore.add(this._activeSession.wholeRange.onDidChange(updateWholeRangeDecoration));