-
-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve snippet-insertion. #941
Conversation
22d4a1a
to
83cacad
Compare
Leaving the current node upon insertion should work now, here's a short demo (because I'm enjoying this very much :D) 1688741136.mp4Notice how the extmark-highlights are dis/enabled when leaving the current node/entering the node the snippet is expanded in, and how the jumps behave as expected An issue with this new behaviour is that enabling |
The demo video file seems to be corrupt so I can't see for certain, but I assume this PR is ready for testing? I'll give it a go if so. |
Oh that would be awesome, thank you! |
d9f591e
to
37a393a
Compare
Alright, got the ones I know about, feel free to take it for a drive :D |
I hope this bug reporting isn't too barren, I've got time to try it out but not much time to do in-depth debugging. This is the first error I've encountered
This happened while autocompleting ['<Tab>'] = cmp.mapping(function(fallback)
if luasnip.expandable() and not cmp.get_selected_entry() then
luasnip.expand()
cmp.close()
elseif cmp.visible() then
cmp.confirm({ select = true })
else
fallback()
end
end, { 'i', 's' }), Let me know if you need anymore information. |
Aaah, I guess this happens if a deleted snippet exists while inserting a new one.. Should be an easy fix 🤞 |
89db67a
to
56d9997
Compare
Took a bit too long, but that should be that |
25491aa
to
3fa6984
Compare
I wouldn't say long but rather very quick 😄. Anyhow I haven't experienced any other bugs. I haven't used it extensively however but will do so in the coming days. If I encounter anything I'll let you know, but so far a very nice improvement! |
fc13544
to
62c5711
Compare
Seems that I might not have actually tested this pr after reporting the first bug, I thought
I'm certain I've merged this pr locally now so I'll continue to use it and see if any errors pop up. |
True, I should've said that it was a bit more than I anticipated :D I think this is in really good shape now, maybe one or two small errors in the last few commits, but all the big pieces, so to speak, are in place, and should work Thank you, I'm very happy to finally get rid of that pain-point :) |
Oh, it must've worked, the traceback contains code only present in this PR |
What exactly do you mean by that? The text inserted into the buffer after expanding the snippet? |
Jup, just that. |
a086adc
to
88043f6
Compare
Found one :) The following auto-snippet: s(
{
trig = ';([^;]*);',
wordTrig = false,
regTrig = true,
trigEngine = 'ecma',
},
fmta('_<>', {
d(
1,
function(_, snip)
return string.len(snip.captures[1]) > 1
and sn(1, t(string.format('{%s}', snip.captures[1])))
or sn(1, t(snip.captures[1]))
end
),
})
), And relevant config: luasnip.config.setup({
history = true,
update_events = 'TextChanged,TextChangedI',
}) Then |
Ahhhhh it's because we don't yet have a fix for this from main on here xD |
12426d5
to
9782d42
Compare
a24ae60
to
8ecab5f
Compare
d2c77fa
to
1321a35
Compare
The video is not corrupted, you are probably using firefox and it does not play the videos @L3MON4D3 uploads. |
1697f69
to
214d145
Compare
A few words on the latest changes (because they don't seem to stop 😅): The obvious solution is to disable So, |
fe6240e
to
8e79ffa
Compare
5593d42
to
8c4332b
Compare
6f964fb
to
bb3f44b
Compare
Before this, upon expanding a new snippet, its jumps were linked up with the currently active node, no matter its position in the buffer. The most prominent negative side-effect of this is jumping all over the buffer if a snippet is not jumped "through" (ie. to its $0). This finally adresses this properly by inserting snippets into nodes according to their position in the buffer. Read the changes to `DOC.md` for more info. This commit also deprecates `history` in `setup`, prefer the new options `keep_roots`, `link_roots`, and `link_children`, as they are more readable. Still, it is very unlikely that compatibility with `history` will ever be completely removed, so no need to fret about this.
now parents update children, and children parents.
3e5a59b
to
2bd74f6
Compare
Right now we handle snippet-insertion (how the snippet is jumped to/from, if
history
is enabled) pretty naively, by always inserting the snippet inside the currently active node. This leads to annoying issues (jumping back far in the buffer, snippets aren't jumped into when jumping from an buffer-position-adjacent one), whose symptoms could be eliminated with things likeregion_check_events
, but it's time for a proper solution.This PR fixes these issues by always inserting the snippet at the node which contains the position it is expanded at, and by leaving the currently active snippet if the new snippet is not inside it.
This also enables an easy fix for #859, since we now know exactly which node has to be updated when the text in a nested snippet is changed.
It should also make unlinking snippets due to deleted text more reliable, right now we look for also-affected snippets by following
node.next/prev
(essentially by simulatingjump(1)
which is kind of stupid tbh), but if we have a proper tree of expanded snippets, this can be implemented much better (I think :D)This is by no means finished, but the searching and insertion is implemented, leaving the current snippet and the other fixes enabled by this don't work yet