Treat ${0} as the final snippet tab stop #30

Merged
marijn merged 1 commit from ondrejmirtes/autocomplete:snippet-final-stop into main 2026-06-02 21:14:50 +02:00
Contributor

Snippet field order is by number, but ${0} should be the final/exit stop --
the position the cursor lands on after tabbing through the other fields --
matching the convention used by TextMate, LSP, VS Code, and others. It was
treated as plain field 0 and sorted first, so a snippet like foo(${1:bar})${0}
selected the empty ${0} instead of bar.

This orders ${0} after every other field (numbered and named), so the first
real placeholder is selected and ${0} becomes the exit. Documented in the
snippet docstring; test added.

Snippet field order is by number, but `${0}` should be the final/exit stop -- the position the cursor lands on after tabbing through the other fields -- matching the convention used by TextMate, LSP, VS Code, and others. It was treated as plain field 0 and sorted first, so a snippet like `foo(${1:bar})${0}` selected the empty `${0}` instead of `bar`. This orders `${0}` after every other field (numbered and named), so the first real placeholder is selected and `${0}` becomes the exit. Documented in the `snippet` docstring; test added.
Snippet field order is by number, but ${0} should be the exit stop -- the
position the cursor lands on after tabbing through the other fields -- to match
the convention used by TextMate, LSP, VS Code, and others. It was sorted first
(as field 0), so a snippet like foo(${1:bar})${0} selected the empty ${0}
instead of bar. Order ${0} after every other field.
Owner

I'd prefer an if (seq == 0) seq = 1e9 at line 53, for simplicity. Want to amend the patch or shall I?

I'd prefer an `if (seq == 0) seq = 1e9` at line 53, for simplicity. Want to amend the patch or shall I?
ondrejmirtes force-pushed snippet-final-stop from 94ceb537d3 to 2557b9a771 2026-06-02 21:04:58 +02:00 Compare
Author
Contributor

I force-pushed with your suggestion. Thank you!

I force-pushed with your suggestion. Thank you!
marijn merged commit 8645ac925a into main 2026-06-02 21:14:50 +02:00
Owner

Thanks! Merged.

Thanks! Merged.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/autocomplete!30
No description provided.