-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
fix(completion): stop completion when completion is exhausted #28558
base: master
Are you sure you want to change the base?
Conversation
0b9b14e
to
957c8ec
Compare
No tests? |
Problem: Currently, completion is not stopped when completion is exhausted (no matching completion items), which also means `CompleteDone` is not called either. Furthermore, `CompleteDone` is called when pressing a special character (Backspace, Space, Esc) instead. Solution: Correctly stop completion and trigger `CompleteDone` when completion is exhausted.
957c8ec
to
14a7bb4
Compare
Added a regression test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this change is correct. After this change, typing backspace after completion is exhausted can no longer resume completion. For example:
- Run
:set completeopt+=noinsert
- Type
i<C-X><C-V>
- Type
a
- Type
a
- Type
<BS>
Without this PR the <BS>
resumes completion. With this PR it doesn't.
@mfussenegger thoughts? |
I guess we now know why exhaustion does not trigger |
Why does local fp = io.open("/tmp/nvim.log", "a+")
vim.o.completeopt = "menuone,noinsert"
vim.api.nvim_create_autocmd("CompleteDone", {
callback = function()
fp:write("called\n")
fp:flush()
end
})
vim.keymap.set("i", "<C-s>", function()
vim.fn.complete(vim.fn.col("."), {"abcd", "abdc", "acbd"})
end) With |
I think it might be better to implement the |
@mfussenegger @justinmk Would it make sense to add something like |
why do we need a new function, could it be a new arg on the existing complete() ? or perhaps |
A new arg on complete might work, yes, but the reason I suggested a new API is that a completion provider might want its completion items list to be regenerated when refreshing completion, so taking in a callback instead of a list of items would be useful in that case |
Problem: Currently, completion is not stopped when completion is exhausted (no matching completion items), which also means
CompleteDone
is not called either. Furthermore,CompleteDone
is called when pressing a special character (Backspace, Space, Esc) instead.Solution: Correctly stop completion and trigger
CompleteDone
when completion is exhausted.