Skip to content

Improve UX of let/let mut snippet cursor placement in block expressions - #23294

Open
mfroeh wants to merge 1 commit into
rust-lang:masterfrom
mfroeh:improve-let-snippet-cursor-placement
Open

Improve UX of let/let mut snippet cursor placement in block expressions#23294
mfroeh wants to merge 1 commit into
rust-lang:masterfrom
mfroeh:improve-let-snippet-cursor-placement

Conversation

@mfroeh

@mfroeh mfroeh commented Sep 4, 2026

Copy link
Copy Markdown

Presently, the focus after navigating let/let mut snippets in block expressions ends up just before the semicolon inserted by the snippet.

When using clients that do not allow navigating over semicolons located to the right of the cursor by pressing ; (e.g. Zed), this leads to annoying UX, since if the user wants to continue editing after the let/let mut statement (arguably always in the next line), they cannot simply press Enter to end up on the next line.

This PR addresses that by adding another snippet navigation stop after the semicolon, allowing the user to navigate past it as part of snippet expansion.

A potential downside with making this the default is if users have come to rely upon the snippet navigation having completed after navigating once. Clients may be within a "in_snippet" context, before users have navigated to $0 (e.g. Zed). Users could have configured their keybindings to function differently within this context, and may be surprised to still have the "in_snippet" behavior of their keybinding, after navigating within the let/let mut snippet once.

I hope this default behavior change can make it regardless, since I believe it improves upon UX, but I can understand if it doesn't, due to the issue laid out above.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 4, 2026

@A4-Tacks A4-Tacks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I once designed it like this, look: #19735 (comment)

View changes since this review

@mfroeh

mfroeh commented Sep 5, 2026

Copy link
Copy Markdown
Author

I once designed it like this, look: #19735 (comment)

View changes since this review

Ah interesting!
Your original design with just $1 and $2 seems to have the same behavior as the $1 $2 $0 one I introduced here.
I couldn't find any reasoning in the PR as to why $1 $2 did not make it through, beyond the requested change.
Could you perhaps elaborate on why this was deemed unwanted? Or did you simply adjust to the requested changes?

@A4-Tacks

A4-Tacks commented Sep 5, 2026

Copy link
Copy Markdown
Member

I don't know, but @Veykril

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants