mirror of
https://github.com/hexedtech/codemp-vscode.git
synced 2024-11-25 00:44:48 +01:00
fix: remove cursors from inactive files
This commit is contained in:
parent
e6b86d3cff
commit
14144ec152
1 changed files with 16 additions and 2 deletions
|
@ -79,19 +79,33 @@ export async function join(selected: vscode.TreeItem | undefined) {
|
|||
}
|
||||
});
|
||||
|
||||
let once = true;
|
||||
vscode.window.onDidChangeTextEditorSelection(async (event: vscode.TextEditorSelectionChangeEvent) => {
|
||||
if (event.kind == vscode.TextEditorSelectionChangeKind.Command) return; // TODO commands might move cursor too
|
||||
let buf = event.textEditor.document.uri;
|
||||
let selection: vscode.Selection = event.selections[0]
|
||||
let buffer = mapping.bufferMapper.by_editor(buf)
|
||||
if (buffer === undefined) return;
|
||||
let cursor: codemp.Cursor = {
|
||||
if (buffer === undefined) {
|
||||
if (once) {
|
||||
await controller.send({
|
||||
startRow: 0,
|
||||
startCol: 0,
|
||||
endRow: 0,
|
||||
endCol: 0,
|
||||
buffer: "",
|
||||
});
|
||||
}
|
||||
once = false;
|
||||
} else {
|
||||
await controller.send({
|
||||
startRow: selection.anchor.line,
|
||||
startCol: selection.anchor.character,
|
||||
endRow: selection.active.line,
|
||||
endCol: selection.active.character,
|
||||
buffer: buffer,
|
||||
user: undefined,
|
||||
});
|
||||
once = true;
|
||||
}
|
||||
await controller.send(cursor);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue