Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Always terminate a snippet when the cursor leaves a tab stop… #273
… even if it moves into a transformed tab stop of the same index.
Description of the Change
Consider this snippet:
You invoke its tab trigger and type
Scenario 3 should behave identically to scenarios 1 and 2.
This happens because we’re not checking whether the cursor remains inside a specific marker. I was worried that fixing this would require us to do a lot of bookkeeping on cursor/marker relationships, but here’s why that can be avoided:
So the fix is targeted: for the snippet to stay active after the cursor moves, it must remain inside of the marker for an insertion that is not a transformation.
Before I realized that I could do this in just a few lines, I’d introduced a whole system for tracking the active marker of each cursor and comparing it to its previous marker when the cursor moved. That also worked. But this is, uh, way simpler.
This fixes a bug with one of the snippets I had in mind when I wrote #260.
Expand that snippet, type
This PR fixes that by ensuring that a marker for a transformation never allows a cursor to move inside of it without terminating the snippet. The new unit test is based on the example above.
It’s not at all intuitive that this code change produces this outcome, which is why I tried to comment this code exhaustively.
None, as far as I can tell.