fix: remove cursors from inactive files

This commit is contained in:
frelodev 2024-10-01 18:54:30 +02:00
parent e6b86d3cff
commit 14144ec152

View file

@ -79,19 +79,33 @@ export async function join(selected: vscode.TreeItem | undefined) {
} }
}); });
let once = true;
vscode.window.onDidChangeTextEditorSelection(async (event: vscode.TextEditorSelectionChangeEvent) => { vscode.window.onDidChangeTextEditorSelection(async (event: vscode.TextEditorSelectionChangeEvent) => {
if (event.kind == vscode.TextEditorSelectionChangeKind.Command) return; // TODO commands might move cursor too if (event.kind == vscode.TextEditorSelectionChangeKind.Command) return; // TODO commands might move cursor too
let buf = event.textEditor.document.uri; let buf = event.textEditor.document.uri;
let selection: vscode.Selection = event.selections[0] let selection: vscode.Selection = event.selections[0]
let buffer = mapping.bufferMapper.by_editor(buf) let buffer = mapping.bufferMapper.by_editor(buf)
if (buffer === undefined) return; if (buffer === undefined) {
let cursor: codemp.Cursor = { if (once) {
await controller.send({
startRow: 0,
startCol: 0,
endRow: 0,
endCol: 0,
buffer: "",
});
}
once = false;
} else {
await controller.send({
startRow: selection.anchor.line, startRow: selection.anchor.line,
startCol: selection.anchor.character, startCol: selection.anchor.character,
endRow: selection.active.line, endRow: selection.active.line,
endCol: selection.active.character, endCol: selection.active.character,
buffer: buffer, buffer: buffer,
user: undefined, user: undefined,
});
once = true;
} }
await controller.send(cursor); await controller.send(cursor);
}); });