This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Define default ending tab stop at the end of the snippet #239
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.
TextMate manual specifies that if no ending tab stop has been defined explicitly, it should be added to the end of snippet:
For tab stops that do not contain a placeholder, this is behavior wise fine (but will not follow spec), but if the last defined tab stop happens to be a placeholder that is not being replaced, this happens (does not have to be necessarily at the end of the snippet):
This pull request checks after processing the tab stops whether the end tab stop is defined (
$0
) or the last tab stop is already at the end. Otherwise it will include a zero-width end stop to the end of the snippet. TextMate only checks the first condition, second condition was added as means of maintaining compatibility with incorrectly-written end-stops for now. Perhaps this should be presented as warning now and removed after a couple of releases.This however does not fix the case where the explicitly defined end tab stop is a placeholder (
${0:placeholder}
), which will behave as the first image. TextMate in this case simply overwrites it with a tab, as that is the default behavior of selected text + tab. Atom's behavior of indenting the whole line when any character is selected, does not work very well together with this. Split into atom/atom#15096Attempt to fix this issue revealed a regression in a test that does not sufficiently cover the regression it was supposed to prevent, which I do not know how to fix. Namely test for
t6
fails, which expands the snippet and then calls undo, which deletes all expanded text up to the zero-width end tab stop, which still exists. Calling tab again does not expandt6
, but jumps to the position of that end tab stop. Without this pull request, but explicitly defining$#
(can be any number) at the beginning/end of that snippet will fail the test as well. Split into #261It should be obvious that I am not expecting this pull request to be merged before these issues have been solved.