preview_lines #4

Merged
Fabel merged 4 commits from preview_lines into develop 2024-10-09 18:00:32 +00:00
2 changed files with 30 additions and 16 deletions
Showing only changes of commit a3bf2f93bb - Show all commits

View File

@ -4,7 +4,7 @@
"displayName": "Fabelous Autocoder",
"description": "A simple to use Ollama autocompletion Plugin",
"icon": "icon.png",
"publisher": "fabel",
"publisher": "Falko Habel",
"license": "CC BY-ND 4.0",
"bugs": {
"url": "https://gitea.fabelous.app/fabel/Fabelous-Autocoder/issues"
@ -114,11 +114,16 @@
}
},
"keybindings": [
{
"command": "fabelous-autocoder.handleTab",
"key": "tab",
"when": "editorTextFocus && !editorTabMovesFocus"
}
{
"command": "fabelous-autocoder.handleTab",
"key": "tab",
"when": "editorTextFocus && !editorTabMovesFocus"
},
{
"command": "fabelous-autocoder.handleBackspace",
"key": "backspace",
"when": "editorTextFocus"
}
],
"commands": [
{

View File

@ -159,13 +159,21 @@ class CompletionManager {
edit.replace(this.document.uri, rangeToReplace, contentToInsert);
await vscode.workspace.applyEdit(edit);
this.clearPreview(); // Clear the preview decorations
// Clear the preview decorations
this.clearPreview();
// Set activeCompletionManager to null
activeCompletionManager = null;
// Calculate the new cursor position from the inserted content
const lastCompletionLine = completionLines[completionLines.length - 1];
const newPosition = new vscode.Position(this.startPosition.line + numberOfLines - 1, lastCompletionLine.length);
const newPosition = new vscode.Position(
this.startPosition.line + numberOfLines - 1,
lastCompletionLine.length
);
// Set the new cursor position without any additional move
// Set the new cursor position
this.textEditor.selection = new vscode.Selection(newPosition, newPosition);
}
@ -204,6 +212,7 @@ class CompletionManager {
this.textEditor.selection = new vscode.Selection(this.startPosition, this.startPosition);
console.log(`Lines ${startLine + 1} to ${endLine + 1} removed successfully`);
activeCompletionManager = null;
} else {
console.log('No lines to remove');
}