Merge multi-snippet common field, fix #921 #924
Merged
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.
Should fix #921
Currently the
common
field is replaced as a whole when the passed arg has this field set instead of merging the passed arg and the extend arg, which is not expected.To clarify, consider the following cases:
I create some luasnip conds and define a new multi-snippet that only expand if ts is not active or ts and active and the cursor is not in a comment or string:
Then I want to create a multi-snippet with regex trigger and only expand when the cursor is not in a comment or string:
the original condition field is dropped because I provide the
common
field in the new snippet, making the originalcommon
table completely replaced by the new one i.e.{ regTrig = true, condition = nil, show_condition = nil, ... }
I would suggest using
vim.tbl_deep_extend
to merge thecommon
table, this fixes the issue (in functionextend_multisnippet_contexts
: