LuaSnip
LuaSnip copied to clipboard
Improve behaviour in macros
Currently, there are a few issues with recording and replaying a snippet-expansion via a macro:
- autosnippets are not expanded at all (#1243) This is because we use a TextChangedI-hook for triggering them, but this is not called while the typeahead is non-empty, which is the case when replaying a macro
- inputs are not inserted correctly into insertNodes
This happens because we have to use
feedkeysto select nodes and move the cursor around, and currently use"n", which appends to the typeahead, which currently contains all the keys of the macro, which means that the jump in the replay is performed at another point in time than in the original session.
This patch solves both of these problems by building a kind of queue that inserts the actions we want to perform at the beginning of the typeahed (so they happen at the correct time when being replayed!) while also maintaining the order in which the actions were inserted (an action will complete before an action enqueued after it will begin execution)
In practice, this slightly roundabout way of doing things should not be noticeable, and ensure correct ordering of all actions that use the feedkeys-mechanism.
Here's a quick example of the flawless replay :)
https://github.com/user-attachments/assets/cce841fe-fc01-4fa6-8744-2e5e0a8e8af3