fix: wrap vim.fn.complete into pcall when adding to dot repeat #2018
+2
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
There’s a window(
resolve_timeout_ms
) where you can do anything (like switch to Normal mode) between selecting a completion item and LSP resolving it. The problem is thatvim.fn.complete
throws an error outside of Insert mode. So if you typeTab -> Esc
you can hit this problem if an LSP will take some time to resolve. Happens to me every day or two.Solution: Wrap it into
pcall
and notify a user that dot repeat logic is failed. But I am not sure about the message format, maybe you can find a better one.Before
before.mp4
After
after.mp4
But it opens up another problem. As you can see in the "after" demo, there's an incorrect t character left at the end of the completion. This happens because switching to Normal mode decreases the cursor's column position by 1, so the last character isn’t cleared.
Still, I think it’s better to deal with an extra character than with the original error.
I described more about this there #1491.