Repository navigation
Go to Selection Anchor: reveal the anchor position - #350427
Merged
Alexandru Dima (alexdima) merged 1 commit intoNov 28, 2026
Merged
Conversation
Go to Selection Anchor moved the cursor to the anchor without asking the editor to reveal it, so the anchor stayed off-screen until the next key press. Reveal the position (centered when outside the viewport), like other navigation commands do. Fixes #347657 🤖 Authored with GitHub Copilot on behalf of @alexdima. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change that brings off-screen selection anchors into view.
No open issues 🎉
What changed in this PR
Fixes #347657 by making Go to Selection Anchor bring off-screen anchors into view, consistent with other editor navigation commands.
Changes:
- Requests a smooth, centered reveal when the anchor is outside the viewport.
- Exports
SelectionAnchorControllerand adds a regression test for the cursor destination and reveal request.
No actionable findings remain.
| File | Description |
|---|---|
src/vs/editor/contrib/anchorSelect/test/browser/anchorSelect.test.ts |
Verifies navigation restores the anchor position and requests the expected reveal. |
src/vs/editor/contrib/anchorSelect/browser/anchorSelect.ts |
Reveals the anchor after moving the cursor and exports the controller for testing. |
Review effort: Balanced
Alexandru Dima (alexdima)
marked this pull request as ready for review
November 28, 2026 19:13
Alexandru Dima (alexdima)
enabled auto-merge
November 28, 2026 19:13
Christof Marti (chrmarti)
approved these changes
Nov 28, 2026
Bhavya U (bhavyaus)
approved these changes
Nov 28, 2026
Bhavya U (bhavyaus)
left a comment
Collaborator
There was a problem hiding this comment.
Small, low-risk fix: Go to Selection Anchor now reveals the anchor via the same reveal used by other navigation commands. Diff and new test look right, and CI is green.
Alexandru Dima (alexdima)
deleted the
agents/fix-go-to-selection-anchor-reveal
branch
November 28, 2026 21:34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #347657
When you set a selection anchor, scroll away from it and run Go to Selection Anchor, the cursor moves to the anchor but the editor does not scroll. The anchor stays off-screen until you press an arrow key or type.
Demo
Change
SelectionAnchorController.goToSelectionAnchor()only callededitor.setPosition(). That moves the cursor but asks for no reveal. It now also callseditor.revealPositionInCenterIfOutsideViewport(position, ScrollType.Smooth). This is the same reveal that other navigation commands use, such as Go to Definition (goToCommands.ts), Go to Next Problem (gotoErrorWidget.ts) and fold navigation (folding.ts). When the anchor is already visible, the view does not move. When it is off-screen, it is centered.SelectionAnchorControlleris now exported so that the new unit test can get it from a test editor.How it was tested
./scripts/test.sh --runGlob '**/anchorSelect.test.js': the new test "Go to Selection Anchor reveals the anchor" passes. Without the fix it fails, because no reveal is requested (reveals: []).pnpm run oxlint src/vs/editor/contrib/anchorSelect/browser/anchorSelect.ts src/vs/editor/contrib/anchorSelect/test/browser/anchorSelect.test.ts: no problems.pnpm run typecheck-client: passed.Before / after
Before
issue-347657-go-to-selection-anchor-insiders.mp4
After
issue-347657-after-fix.mp4
🤖 Authored with GitHub Copilot on behalf of Alexandru Dima (@alexdima).