Skip to content

Scroll to follow expanding part of editor::SelectLargerSyntaxNode#27295

Merged
marcospb19 merged 6 commits intomainfrom
improve-scroll-when-selecting-larger-node
Mar 22, 2025
Merged

Scroll to follow expanding part of editor::SelectLargerSyntaxNode#27295
marcospb19 merged 6 commits intomainfrom
improve-scroll-when-selecting-larger-node

Conversation

@marcospb19
Copy link
Copy Markdown
Contributor

@marcospb19 marcospb19 commented Mar 22, 2025

When the selection grows both ways, the new code prioritizes the top part instead of bottom one, this is usually more helpful considering that most programming language grammars tend to define tokens right before large delimited blocks, and rarely after (because humans and parsers read from top to bottom).

Also, revert selection when convenient, so you have more control over what you're selecting, looking at the selection head is commonly more convenient than at the tail.

Also, if you scroll away editor::SelectSmallerSyntaxNode will do a better job at restoring you to the position you were before.

Release Notes:

  • Improve scrolling of editor::SelectLargerSyntaxNode for better visibility.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 22, 2025
@marcospb19 marcospb19 enabled auto-merge (squash) March 22, 2025 08:26
@marcospb19 marcospb19 merged commit 9918b6c into main Mar 22, 2025
15 checks passed
@marcospb19 marcospb19 deleted the improve-scroll-when-selecting-larger-node branch March 22, 2025 09:06
P1n3appl3 added a commit that referenced this pull request Apr 7, 2025
With #27295, the cursor would center upon running
`SelectLargerSyntaxNode`. This was done to provide more context when
making large selections, but when making small selections (such as a
single parameter in an argument list) it was confusing that the scroll
position jumped.

This change makes that behavior slightly more conservative: now when the
selection is small enough to fit on the screen scrolling will only occur
to keep the cursor position on the screen (including respecting
`vertical_scroll_margin`).

Release Notes:

- N/A

Co-authored-by: João Marcos <marcospb19@hotmail.com>
smitbarmase added a commit that referenced this pull request Mar 17, 2026
…ith multiple cursors (#51752)

Closes #47737

Regressed by #27295

Release Notes:

- Fixed an issue where using the `SelectLargeSyntaxNode` action with
multiple cursors could reverse the selection direction for the last
cursor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant