This repository was archived by the owner on Dec 15, 2022. It is now read-only.
When hitting tab within the last tab stop, jump to end of tab stop and terminate the snippet expansion #262
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.
Description of the Change
Previously, when you hit
tab
inside the last tab stop of a snippet, it would be treated as an ordinarytab
.Now, to bring Atom's behavior more in line with Sublime Text, hitting tab within the last tab stop moves the cursor to the end of the tab stop and terminates the snippet expansion. From this point forward, the tab stops will no longer be present and
tab
will function as it normally does.This PR also moves tab stop markers into their own marker layer so that they can be managed with the history. I had hoped this would enable you to cycle through tab stops after expanding, undoing, and redoing, but there is a bug in restoring markers that will need to be fixed before that will work.
Benefits
This prevents us from leaking markers and provides a somewhat more intuitive experience for eliminating tab stops.
Alternate Designs
Ultimately, I think we need to rethink our approach to tab stops entirely. It would be better to enter a snippet editing mode that highlighted the tab stops in a different color and that you exit either by hitting escape or by tabbing off the end. That's a bigger project though.
Possible Drawbacks
It may be surprising that tab doesn't indent code when editing the last tab stop until the tab stop is completely dismissed.
Applicable Issues
Fixes #248
/cc @50Wliu