From 77e0dbc04898ef5b952bd3e65ac6ed1f21182cba Mon Sep 17 00:00:00 2001 From: Falko Habel Date: Wed, 11 Sep 2024 09:54:28 +0200 Subject: [PATCH] not working multi line support --- src/extension.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index d2b801b..15fd0fe 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -110,11 +110,16 @@ async function autocompleteCommand(textEditor: vscode.TextEditor, cancellationTo // Split the completion text by new lines const lines = completionText.split('\n'); - + // Create a decoration for each line of the response const previewRanges = lines.map((line: string, idx: number) => { - const linePos = new vscode.Position(position.line + idx, 0); - const range = new vscode.Range(linePos, linePos); // Set range at the start of each new line + // Determine the start and end positions for each line + const startPos = new vscode.Position(position.line + idx, 0); + const endPos = new vscode.Position(position.line + idx, line.length); + + // Create a range covering the whole line + const range = new vscode.Range(startPos, endPos); + return { range, renderOptions: { @@ -126,7 +131,7 @@ async function autocompleteCommand(textEditor: vscode.TextEditor, cancellationTo } }; }); - + // Apply the decorations for multiline preview textEditor.setDecorations(previewDecorationType, previewRanges);