fix: less cursor flickering

dont dispose every time, just update decoration position
This commit is contained in:
əlemi 2024-09-16 03:18:06 +02:00
parent 46d932983f
commit 73b3c31ac1
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -40,20 +40,25 @@ export class UserDecoration {
// TODO can we avoid disposing and recreating the decoration type every time?
public apply(editor: vscode.TextEditor, event: codemp.Cursor) {
if (this.decoration !== null) {
this.decoration.dispose();
if (this.decoration == null) {
this.decoration = vscode.window.createTextEditorDecorationType({
borderWidth: '1px',
borderStyle: 'solid',
borderColor: this.color,
backgroundColor: this.color + '44', // add alpha
});
}
this.decoration = vscode.window.createTextEditorDecorationType({
borderWidth: '1px',
borderStyle: 'solid',
borderColor: this.color,
backgroundColor: this.color + '44', // add alpha
});
const range_start: vscode.Position = new vscode.Position(event.startRow, event.startCol); // -1?
const range_end: vscode.Position = new vscode.Position(event.endRow, event.endCol); // -1? idk if this works it's kinda funny, should test with someone with a working version of codemp
const decorationRange = new vscode.Range(range_start, range_end);
editor.setDecorations(this.decoration, [decorationRange]);
}
public clear() {
if (this.decoration !== null) {
this.decoration.dispose();
}
}
}