You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Probably by disturbing/clobbering extmarks in the current line.
How I stumbled upon the bug
Expand a LuSnip snippet that includes choices (i.e. includes a single choice node within, somewhere in the middle among a couple other nodes). For simplicity, just use a single-line snippet.
<Esc> to normal mode, and then manually position the cursor at EOL (if it isn't already there).
Accept copilot suggestion with <M-l> "accept" which extends the current line.
Now, cycle snippet choices (e.g. via keymap). Instead of the choices cycling at the proper position within the line (as they would otherwise), the position will be all screwed up (e.g. always at the very begging of the current line).
I know that LuSnip uses extmarks to track the position of the expanded snippet, so I believe that the issue has something to do with this plugin (copilot.lua) disturbing those extmarks when inserting the suggestion text. I mean it could also be a LuaSnip issue (extmark config/gravity settings), but I think that this is less likely. Might need further investigation.
Idk how this plugin handles inserting the suggestion text, but if it always just replaces the entire line, then that would explain why the extmarks are getting ruined.
Example/Reproduction
-- You will need to have both luasnip and copilot.lua installed/setup, and the-- latter should be active for this buffer (or on Lua buffers).---- 1. Paste this into a new buffer.-- 2. Run `:%lua` at the cmdline.-- 3. Press `<Esc>` to exit select mode.-- 4. Press `A` to enter insert mode at the EOL.-- 5. Type a space and wait for copilot suggestion.-- 6. Accept the suggestion (e.g. `<M-l>`).-- 7. Cycle snippet choices with `<S-Tab>` and observe the bug.---- To observe the correct behavior, repeat these steps but skip step 6.localls=require'luasnip'vim.bo.ft='lua'vim.keymap.set(
{ 'n', 'i', 'v' },
'<S-Tab>',
function() ls.change_choice(1) end,
{ buffer=0 }
)
vim.cmd[[normal! G2o]]ls.snip_expand(ls.s({}, {
ls.t'-- What does ',
ls.c(1, { ls.i(1, '1 + 2'), ls.i(1, '2 + 3') }), -- Choice nodels.t' equal? The answer is',
}))
The text was updated successfully, but these errors were encountered:
tmillr
changed the title
Accepting suggestion with <M-l> ruins current expanded snippet (LuaSnip)
Accepting suggestion with <M-l> ruins expanded snippet (LuaSnip)
Sep 6, 2024
Probably by disturbing/clobbering extmarks in the current line.
How I stumbled upon the bug
LuSnip
snippet that includes choices (i.e. includes a single choice node within, somewhere in the middle among a couple other nodes). For simplicity, just use a single-line snippet.<Esc>
to normal mode, and then manually position the cursor at EOL (if it isn't already there).<M-l>
"accept" which extends the current line.I know that
LuSnip
uses extmarks to track the position of the expanded snippet, so I believe that the issue has something to do with this plugin (copilot.lua
) disturbing those extmarks when inserting the suggestion text. I mean it could also be aLuaSnip
issue (extmark config/gravity settings), but I think that this is less likely. Might need further investigation.Idk how this plugin handles inserting the suggestion text, but if it always just replaces the entire line, then that would explain why the extmarks are getting ruined.
Example/Reproduction
The text was updated successfully, but these errors were encountered: