diff options
author | Daniel RodrÃguez Rivero <[email protected]> | 2022-09-07 09:09:00 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2022-09-07 09:09:00 +0200 |
commit | 461203bf25a41d7ae3d134c5b3a0f61443158fd2 (patch) | |
tree | b7887a11987a1a6e54c1cd67bfecb722245e6890 /lua | |
parent | e485cd6e406b8ba8e5d02a87db954a1d924036ce (diff) |
fix(cmp): fix cmp select on CR (#2980)
* fix(cmp): fix cmp select on CR
When cmp prompt is open and nothing is selected <cr> did nothing
Also fixes snippets texts being overwritten when you select an option
fixes #2977
* fixup!: little refactor
Diffstat (limited to 'lua')
-rw-r--r-- | lua/lvim/core/cmp.lua | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/lua/lvim/core/cmp.lua b/lua/lvim/core/cmp.lua index 7b0b0e6e..408691a6 100644 --- a/lua/lvim/core/cmp.lua +++ b/lua/lvim/core/cmp.lua @@ -272,20 +272,15 @@ M.config = function() if is_insert_mode() then -- prevent overwriting brackets confirm_opts.behavior = cmp.ConfirmBehavior.Insert end - cmp.confirm(confirm_opts) - if jumpable(1) then - luasnip.jump(1) + if cmp.confirm(confirm_opts) then + return -- success, exit early end - return end - if jumpable(1) then - if not luasnip.jump(1) then - fallback() - end - else - fallback() + if jumpable(1) and luasnip.jump(1) then + return -- success, exit early end + fallback() -- if not exited early, always fallback end), }, } |