feat/preview #3
|
@ -108,23 +108,23 @@ async function autocompleteCommand(textEditor: vscode.TextEditor, cancellationTo
|
|||
let completionText = response.data.response;
|
||||
completionText = completionText.replace(/<fim_middle>|<fim_suffix>|<fim_prefix>/g, '').trim();
|
||||
|
||||
// Split the completion text by new lines
|
||||
// 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) => {
|
||||
// Determine the start and end positions for each line
|
||||
// Determine the start position 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);
|
||||
// Create a range that decorates the line, spanning from start to start (empty range)
|
||||
const range = new vscode.Range(startPos, startPos);
|
||||
|
||||
return {
|
||||
range,
|
||||
renderOptions: {
|
||||
before: {
|
||||
contentText: line,
|
||||
after: {
|
||||
contentText: line, // Display the current line
|
||||
color: '#888888',
|
||||
fontStyle: 'italic',
|
||||
}
|
||||
|
@ -135,6 +135,7 @@ async function autocompleteCommand(textEditor: vscode.TextEditor, cancellationTo
|
|||
// Apply the decorations for multiline preview
|
||||
textEditor.setDecorations(previewDecorationType, previewRanges);
|
||||
|
||||
|
||||
let completionInserted = false; // Flag to track insertion
|
||||
|
||||
const disposable = vscode.workspace.onDidChangeTextDocument(async (event) => {
|
||||
|
|
Loading…
Reference in New Issue