mirror of
https://github.com/hexedtech/codemp-vscode.git
synced 2024-11-22 15:34:49 +01:00
fix: less cursor flickering
dont dispose every time, just update decoration position
This commit is contained in:
parent
46d932983f
commit
73b3c31ac1
1 changed files with 13 additions and 8 deletions
|
@ -40,20 +40,25 @@ export class UserDecoration {
|
||||||
|
|
||||||
// TODO can we avoid disposing and recreating the decoration type every time?
|
// TODO can we avoid disposing and recreating the decoration type every time?
|
||||||
public apply(editor: vscode.TextEditor, event: codemp.Cursor) {
|
public apply(editor: vscode.TextEditor, event: codemp.Cursor) {
|
||||||
if (this.decoration !== null) {
|
if (this.decoration == null) {
|
||||||
this.decoration.dispose();
|
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_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 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);
|
const decorationRange = new vscode.Range(range_start, range_end);
|
||||||
editor.setDecorations(this.decoration, [decorationRange]);
|
editor.setDecorations(this.decoration, [decorationRange]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public clear() {
|
||||||
|
if (this.decoration !== null) {
|
||||||
|
this.decoration.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue