-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[READY] Reset the start column in omnifunc completer #2489
Conversation
Note: requires upping the Vim version to 7.4.775 https://github.com/vim/vim/tree/v7.4.775 I think we should wrap in a |
Hmmm, actually this noselect setting has a problem vs what we have now: scope. It applies to everything, whereas our approach only applies to our triggered completions. I just noticed this when using it. Darn. |
Turns out it isn't needed :) woop \o/ Edit: spoke to soon, it is. |
@puremourning Wow you really took that JS-with-single-quotes issue personally. :D I see you're still going through the discovery process here a bit; my preliminary take is that I'm not at all against the approach this PR is taking. We would though just bump our min Vim requirement instead of using |
heh. It was the straw that broke the camel's back. I've said before that i've had about 4 goes at fixing this. I'm still annoyed that it doesn't seem possible without requiring the user to have new I'm thinking that we might have to only enable this if the user herself added Example use-case where it breaks (where I noticed it):
The approach included in this patch doesn't work with the Worth saying, however, that this approach does work for omnifuncs because they are required to return synchronously, so there is hope for omnifuncs, but my javascript completer bug may be harder (or not possible) without blocking the UI thread - which is out of the question. |
A workaround could be to set the Also, may I suggest to move the omnifunc related changes to another PR so that this PR does not depend on updating the ycmd submodule? This would make it easier to test and review the changes. |
I tried setting the completeopt just before feedkeys yesterday and it didn't seem to work. I didn't look into it in detail, but i will try again. |
6a535d7
to
8c0a9e1
Compare
[READY] Rewrite completion system There is a number of issues with the current completion system: - UI is blocked until the completions are returned by the server, the request timed out, or a key is pressed by the user. This leads to a rough experience when completions take too much time: cursor disappearing and timeout errors (see #2192 and #2574). Users even [increase the timeout by manually editing the `completion_request.py` file](https://github.com/Valloric/YouCompleteMe/blob/master/python/ycm/client/completion_request.py#L30) to avoid these errors, which exacerbate the issue and, in some cases, make the plugin unusable (see #2574). - no fuzzy matching from omnifunc when forcing semantic completion. See #961; - no fuzzy matching when deleting characters. Vim filtering is used instead: ![completion-bug-deleting-characters](https://cloud.githubusercontent.com/assets/10026824/26276156/f298c6de-3d71-11e7-92da-d22186239c27.gif) Neovim and MacVim are not affected. - completion menu disappears after deleting a character and inserting one: ![completion-bug-reinserting-character](https://cloud.githubusercontent.com/assets/10026824/26276192/b3ed0f7a-3d72-11e7-8c64-523a0a59cbdc.gif) Neovim and MacVim are not affected. - ignore the start column returned by the server. See PR #2489. - subject to flickers. This one depends a lot on the version of Vim. Completion is almost flicker-free in Neovim and MacVim. Not too bad in console Vim (except in fast terminal like [alacritty](https://github.com/jwilm/alacritty)). Awful in gVim GTK2 (a bit better on GTK3) and gVim on Windows. This PR is an attempt at fixing all of these issues while reducing flickers as best as possible (due to how completion works in Vim, a flicker-free experience is impossible to achieve). Here's how: - poll for completions using a timer and call `completefunc` once the completions are ready. Use the start column returned by the server in `completefunc`; - immediately display the last completions on the `TextChangedI` event to prevent the popup menu disappearing while waiting for the completions. This reduces flickering; - use the `InsertCharPre` event to close the completion menu just before inserting a character. This way the `TextChangedI` event is triggered when the character is inserted (this event is not fired when the completion menu is visible). This replaces the `refresh` option set to `always` in `completefunc` and the `s:cursor_moved` hack; - remap the backspace key to close the completion menu when deleting a character and thus triggering the `TextChangedI` event; - send a request with `force_semantic` set to `True` when forcing semantic completion instead of calling the omnifunc. This fixes the issue where there is no fuzzy matching for custom omnifuncs. Here's a demo where I added a spin animation on the command line while loading the completions to show that it doesn't block the Vim UI: ![async-completion-for-real](https://cloud.githubusercontent.com/assets/10026824/26277295/0f16a718-3d86-11e7-90f3-8a56bbf53f9f.gif) Fixes #961. Fixes #1282. Fixes #1881. Fixes #2192. Fixes #2500. Fixes #2574. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2657) <!-- Reviewable:end -->
☔ The latest upstream changes (presumably #2657) made this pull request unmergeable. Please resolve the merge conflicts. |
Implemented by PR #2657. |
I missed the part where the start column is reset in the omnifunc completer. This would fix issue #1322 but PR ycm-core/ycmd#681 needs to be merged first. Reopening. |
8c0a9e1
to
3638526
Compare
Test case:
function! BenOmniTest( findstart, base )
if a:findstart
" Maker it put everything at the beginning of the line
return 0
endif
" Some random results for testing
return [ 'test', 'testing' ]
endfunction
set omnifunc=BenOmniTest
PASS :) |
When ycm-core/ycmd#681 is merged I will update ycmd submodule and this is ready |
3638526
to
c398450
Compare
I've updated ycmd, so this is now ready. Changes in the ycmd bump:
|
@puremourning looks like the tests are failing :( |
err ok, there's a nonzero chance the tests broke with this change.... |
…er a known failure
OK that should fix the tests. Mostly they were sending the wrong |
Codecov Report
@@ Coverage Diff @@
## master #2489 +/- ##
==========================================
+ Coverage 88.9% 88.91% +<.01%
==========================================
Files 20 20
Lines 1938 1939 +1
==========================================
+ Hits 1723 1724 +1
Misses 215 215 |
Reviewed 1 of 1 files at r2, 1 of 1 files at r3, 1 of 1 files at r4. Comments from Reviewable |
@zzbot r=micbou Reviewed 1 of 1 files at r1, 1 of 1 files at r2, 1 of 1 files at r3, 1 of 1 files at r4. Comments from Reviewable |
📌 Commit 5c98b69 has been approved by |
[READY] Reset the start column in omnifunc completer # PR Prelude Thank you for working on YCM! :) **Please complete these steps and check these boxes (by putting an `x` inside the brackets) _before_ filing your PR:** - [X] I have read and understood YCM's [CONTRIBUTING][cont] document. - [X] I have read and understood YCM's [CODE_OF_CONDUCT][code] document. - [X] I have included tests for the changes in my PR. If not, I have included a rationale for why I haven't. - [X] **I understand my PR may be closed if it becomes obvious I didn't actually perform all of these steps.** # Why this change is necessary and useful A number of issues have been raised over the years where YCM doesn't interact great with the user's omnifunc. This is commonly because we ignore the omnifunc's `findstart` response, and use our own implementation (`base.CompletionStartColumn`). In combination with ycm-core/ycmd#681 this change uses the omnifunc's start column for completions and fixes ycm-core/ycmd#671 and others, such as: - #1322 probably (not yet tested) - #1957 - #1816 Note: This is just an initial test for sharing the code to gauge reaction. Not fully tested yet. [cont]: https://github.com/Valloric/YouCompleteMe/blob/master/CONTRIBUTING.md [code]: https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2489) <!-- Reviewable:end -->
☀️ Test successful - status-appveyor, status-travis |
PR Prelude
Thank you for working on YCM! :)
Please complete these steps and check these boxes (by putting an
x
insidethe brackets) before filing your PR:
rationale for why I haven't.
actually perform all of these steps.
Why this change is necessary and useful
A number of issues have been raised over the years where YCM doesn't interact great with the user's omnifunc. This is commonly because we ignore the omnifunc's
findstart
response, and use our own implementation (base.CompletionStartColumn
).In combination with ycm-core/ycmd#681 this change uses the omnifunc's start column for completions and fixes ycm-core/ycmd#671 and others, such as:
Note: This is just an initial test for sharing the code to gauge reaction. Not fully tested yet.
This change is