Skip to content

Commit

Permalink
Fix embarrasing bug: selection preservation
Browse files Browse the repository at this point in the history
  • Loading branch information
lukstafi committed Nov 30, 2022
1 parent 7f6359e commit d161037
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- When the block scope and the brackets scope are non-containing overlapping, consistently prefer the farther-out target position.
- Many bug fixes.
- Simpler implementation of the scoping logic.
- Selection preservation for the `Select` commands.

### Changed

Expand Down
5 changes: 2 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ export async function goToOuterScope(textEditor: vscode.TextEditor, select: bool
}
return;
}
const anchor = select ? textEditor.selection.anchor : result;
const anchor = select ? savedSelection.anchor : result;
textEditor.selection = new vscode.Selection(anchor, result);
if (!state.lastVisibleRange.contains(textEditor.selection)) {
textEditor.revealRange(textEditor.selection);
Expand Down Expand Up @@ -470,7 +470,6 @@ function findSiblingIndentation(

export async function goPastSiblingScope(textEditor: vscode.TextEditor, select: boolean, before: boolean) {
// State update might interact with the UI, save UI state early.
// FIXME: ensure selection is not broken by JTB mode.
const savedSelection = textEditor.selection;
let state = await updateStateForPosition(textEditor);
const configuration = vscode.workspace.getConfiguration();
Expand Down Expand Up @@ -543,7 +542,7 @@ export async function goPastSiblingScope(textEditor: vscode.TextEditor, select:
}
return;
}
const anchor = select ? textEditor.selection.anchor : targetPos;
const anchor = select ? savedSelection.anchor : targetPos;
textEditor.selection = new vscode.Selection(anchor, targetPos);
// jumpToBracket could have moved the screen.
if (!state.lastVisibleRange.contains(textEditor.selection)) {
Expand Down

0 comments on commit d161037

Please sign in to comment.