helix
helix copied to clipboard
completion fix
Completion will not work correct When We type chars between sended to completion request and recived the result. These chars will not be replaced by completion items.
How to reproduce the issue? Oh, I just realized I have this issue.
I don't quite understand the issue, we track the initial trigger_offset
when completion
is triggered: https://github.com/helix-editor/helix/blob/7eb013c6fb33df40b2fae31c9d08f7da275cd963/helix-term/src/commands.rs#L3490
Then we use that trigger offset when needed: https://github.com/helix-editor/helix/blob/7eb013c6fb33df40b2fae31c9d08f7da275cd963/helix-term/src/ui/completion.rs#L111-L117
We also remove any extra text: https://github.com/helix-editor/helix/blob/7eb013c6fb33df40b2fae31c9d08f7da275cd963/helix-term/src/ui/completion.rs#L133-L134
We might need to call .savepoint
sooner, inside fn completion
rather than here https://github.com/helix-editor/helix/blob/0062af6a19d96e0a4c3f94e3e44c179230e005b9/helix-term/src/ui/completion.rs#L152-L153
We might need to call
.savepoint
sooner, insidefn completion
rather than herehttps://github.com/helix-editor/helix/blob/0062af6a19d96e0a4c3f94e3e44c179230e005b9/helix-term/src/ui/completion.rs#L152-L153
Yes In the current implementation, there are still redundant characters. It occurs when the completion request is sent and wait response. At this time, we type char again.
How to reproduce the issue?
Although it is a small regular event that affects normal editing
gopls 0.7.0 helix 0.6 .config/helix/config.toml
idle-timeout = 40
I've been seeing the same completion problems with ElixirLS and ErlangLS. I'm not sure if it's the slowness of the LS or my low idle-timeout
config but when I type and get completion as I type, C-n
/C-p
ing to one of the candidates does sometimes end up with a suffix like the screenshot. I hadn't really locked down what triggered it but it seems like if I deliberately pause before pressing C-n
/C-p
it doesn't happen (on master).
I just took this branch for a spin though and it seems to solve my completion problems.
~I ran with this change yesterday and I noticed that the completion menu seems to pop up less. I imagine that what's happening is that I trigger the idle-timeout between keystrokes and the keystrokes following the auto-complete request cancel that request. (I haven't really looked at the change yet though so take that description with a grain of salt)~
edit: this is my own doing - going into verbose mode and tailing the logs shows that it's the server that's being slow.
Hey @cossonleo I want to finally get this merged but I'm trying to understand the fix. Does it immediately set a save point, then when completion data arrives it filters that based on new input?
Hey @cossonleo I want to finally get this merged but I'm trying to understand the fix. Does it immediately set a save point, then when completion data arrives it filters that based on new input?
Yes, Method Completion::new()
will call recompute_filter(editor)
to filter the data.
@archseer The PR is ready for merging. Do you have any other suggestions.
Sorry, I'll look at this PR this week!
Looks like my comments didn't get posted last time: I think moving doc.savepoint()
before the callback is the only change needed to fix the completion. Why is savepoint now storing version?
Looks like my comments didn't get posted last time: I think moving
doc.savepoint()
before the callback is the only change needed to fix the completion. Why is savepoint now storing version?
We should discard the completion's result responsed after trigger the next completion. So we need to store the version to determine whether to discard.
On my system, this patch causes completion to fail completely. Logs show
2022-10-06T17:19:39.010 helix_lsp::transport [ERROR] err: <- StreamClosed
2022-10-06T17:19:39.012 helix_lsp::transport [ERROR] err: <- StreamClosed
This is gopls 0.9.5 with go 1.19.2.
EDIT: with hx -vvv
, completion works, but I still get the problems described in #4131.
I think this is the code that handles it in VSCode: https://github.com/microsoft/vscode/blob/ba9399b83d048e780646896d5f81bcc08d759c6b/src/vs/editor/contrib/inlineCompletions/browser/inlineCompletionsModel.ts#L539-L548
I don't have enough context to be confident in my conflict resolutions, but I merged this into master
at https://github.com/rcorre/helix/commit/51f8b6732610b23011f38b2863afa26809b89bf0 and it seems to fix #4851 for me.
Superseded by #6173