preview_develop #2
|
@ -53,12 +53,13 @@ function createFIMPrompt(prefix: string, language: string): string {
|
|||
return `<fim_prefix>${prefix}<fim_middle><fim_suffix>${language}\n`;
|
||||
}
|
||||
|
||||
|
||||
const previewDecorationType = vscode.window.createTextEditorDecorationType({
|
||||
after: {
|
||||
color: '#888888', // Grayed-out preview text
|
||||
fontStyle: 'italic',
|
||||
},
|
||||
isWholeLine: true, // Support multiline properly
|
||||
isWholeLine: true, // Ensure it handles multiline properly
|
||||
});
|
||||
|
||||
async function autocompleteCommand(textEditor: vscode.TextEditor, cancellationToken?: vscode.CancellationToken) {
|
||||
|
@ -119,12 +120,13 @@ async function autocompleteCommand(textEditor: vscode.TextEditor, cancellationTo
|
|||
range,
|
||||
renderOptions: {
|
||||
after: {
|
||||
contentText: line, // Show each line
|
||||
contentText: line, // Show each line properly
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// Set decorations for each line
|
||||
textEditor.setDecorations(previewDecorationType, previewRanges);
|
||||
|
||||
const disposable = vscode.workspace.onDidChangeTextDocument(async (event) => {
|
||||
|
@ -150,7 +152,11 @@ async function autocompleteCommand(textEditor: vscode.TextEditor, cancellationTo
|
|||
const edit = new vscode.WorkspaceEdit();
|
||||
const insertPosition = new vscode.Position(position.line, 0);
|
||||
edit.insert(document.uri, insertPosition, '\n' + completionText);
|
||||
|
||||
// Ensure response is added only once
|
||||
if (!document.getText().includes(completionText)) {
|
||||
await vscode.workspace.applyEdit(edit);
|
||||
}
|
||||
|
||||
const newPosition = new vscode.Position(position.line + lines.length, lines[lines.length - 1].length);
|
||||
textEditor.selection = new vscode.Selection(newPosition, newPosition);
|
||||
|
@ -173,6 +179,7 @@ async function autocompleteCommand(textEditor: vscode.TextEditor, cancellationTo
|
|||
|
||||
|
||||
|
||||
|
||||
async function provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, cancellationToken: vscode.CancellationToken) {
|
||||
const item = new vscode.CompletionItem("Fabelous autocompletion");
|
||||
item.insertText = new vscode.SnippetString('${1:}');
|
||||
|
|
Loading…
Reference in New Issue