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