Skip to content

Commit b29ff9e

Browse files
committed
Fix: avoid sending selection updates after receiving one.
1 parent 0d23d05 commit b29ff9e

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

extensions/VSCode/src/extension.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,15 @@ export const activate = (context: vscode.ExtensionContext) => {
335335
}
336336
if (current_update.contents !== undefined) {
337337
const source = current_update.contents.source;
338-
// Is this plain text, or a diff? This will
339-
// produce a change event, which we'll ignore.
338+
// This will
339+
// produce a change event, which we'll ignore. The change may also produce a selection change, which should also be ignored.
340340
ignore_text_document_change = true;
341+
ignore_selection_change = true;
341342
// Use a workspace edit, since calls to
342343
// `TextEditor.edit` must be made to the active
343344
// editor only.
344345
const wse = new vscode.WorkspaceEdit();
346+
// Is this plain text, or a diff?
345347
if ("Plain" in source) {
346348
wse.replace(
347349
doc.uri,
@@ -389,12 +391,10 @@ export const activate = (context: vscode.ExtensionContext) => {
389391
}
390392
}
391393
}
392-
vscode.workspace
393-
.applyEdit(wse)
394-
.then(
395-
() =>
396-
(ignore_text_document_change = false),
397-
);
394+
vscode.workspace.applyEdit(wse).then(() => {
395+
ignore_text_document_change = false;
396+
ignore_selection_change = false;
397+
});
398398
// Now that we've updated our text, update the associated version as well.
399399
version = current_update.contents.version;
400400
}
@@ -420,6 +420,7 @@ export const activate = (context: vscode.ExtensionContext) => {
420420
// viewport, but a bit below it.
421421
TextEditorRevealType.AtTop,
422422
);
423+
ignore_selection_change = false;
423424
}
424425

425426
let cursor_line = current_update.cursor_position;
@@ -437,6 +438,7 @@ export const activate = (context: vscode.ExtensionContext) => {
437438
cursor_position,
438439
),
439440
];
441+
ignore_selection_change = false;
440442
}
441443
await sendResult(id);
442444
break;

0 commit comments

Comments
 (0)