develop #6
|
@ -108,23 +108,23 @@ async function autocompleteCommand(textEditor: vscode.TextEditor, cancellationTo
|
||||||
let completionText = response.data.response;
|
let completionText = response.data.response;
|
||||||
completionText = completionText.replace(/<fim_middle>|<fim_suffix>|<fim_prefix>/g, '').trim();
|
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
|
// Split the completion text by new lines
|
||||||
const lines = completionText.split('\n');
|
const lines = completionText.split('\n');
|
||||||
|
|
||||||
// Create a decoration for each line of the response
|
// Create a decoration for each line of the response
|
||||||
const previewRanges = lines.map((line: string, idx: number) => {
|
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 startPos = new vscode.Position(position.line + idx, 0);
|
||||||
const endPos = new vscode.Position(position.line + idx, line.length);
|
|
||||||
|
// Create a range that decorates the line, spanning from start to start (empty range)
|
||||||
// Create a range covering the whole line
|
const range = new vscode.Range(startPos, startPos);
|
||||||
const range = new vscode.Range(startPos, endPos);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
range,
|
range,
|
||||||
renderOptions: {
|
renderOptions: {
|
||||||
before: {
|
after: {
|
||||||
contentText: line,
|
contentText: line, // Display the current line
|
||||||
color: '#888888',
|
color: '#888888',
|
||||||
fontStyle: 'italic',
|
fontStyle: 'italic',
|
||||||
}
|
}
|
||||||
|
@ -134,6 +134,7 @@ async function autocompleteCommand(textEditor: vscode.TextEditor, cancellationTo
|
||||||
|
|
||||||
// Apply the decorations for multiline preview
|
// Apply the decorations for multiline preview
|
||||||
textEditor.setDecorations(previewDecorationType, previewRanges);
|
textEditor.setDecorations(previewDecorationType, previewRanges);
|
||||||
|
|
||||||
|
|
||||||
let completionInserted = false; // Flag to track insertion
|
let completionInserted = false; // Flag to track insertion
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue