Previously, when you hit tab inside the last tab stop of a snippet, it would be treated as an ordinary tab.
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.
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