Skip to content

Commit 0ad7888

Browse files
authored
Fix cross-split selections (#233)
1 parent 3344598 commit 0ad7888

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/setSelectionsAndFocusEditor.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ export async function setSelectionsAndFocusEditor(
1818
editor: TextEditor,
1919
selections: Selection[]
2020
) {
21-
await focusEditor(editor);
22-
2321
editor.selections = selections;
24-
editor.revealRange(editor.selections[0]);
22+
editor.revealRange(editor.selection);
23+
24+
// NB: We focus the editor after setting the selection because otherwise you see
25+
// an intermediate state where the old selection persists
26+
await focusEditor(editor);
2527
}
2628

2729
export async function focusEditor(editor: TextEditor) {

0 commit comments

Comments
 (0)