-
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] Use setlocal for temporary completeopt adjustment #4264
Conversation
Since vim 9.1.0469, completeopt is a global-local option. When adding `noselect`, we need to treat `completeopt` as local and use `setlocal`. This works for 9.1.0016 as well and allows users to freely mess with buffer-local `completeopt` without messing up YCM completions.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4264 +/- ##
=======================================
Coverage 89.80% 89.80%
=======================================
Files 37 37
Lines 4758 4758
=======================================
Hits 4273 4273
Misses 485 485 |
@@ -1357,7 +1357,7 @@ function! s:Complete() | |||
endif | |||
if len( s:completion.completions ) | |||
let old_completeopt = &completeopt | |||
set completeopt+=noselect | |||
setlocal completeopt+=noselect | |||
call complete( s:completion.completion_start_column, | |||
\ s:completion.completions ) | |||
let &completeopt = old_completeopt |
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.
Does this set the buffer local or global value? If it was previously globally set does this make it buffer local? I'm not sure that's desirable
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.
This does set the buffer-local value.If it was previously globally set, this does make it buffer-local.
I've manually tested this scenario:
- Do some completion thing, so that we mess with buffer-local
completeopt
. - Manually mess with the global value. At the point, the buffer-local
completeopt
is destroyed, because global config changed. - Do more completion.
That worked as expected and the end result is that both global and buffer-local completeopt
have the same value.
Can you think of more potentially broken scenarios to 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.
Nope. SGTM.
Thanks for sending a PR! |
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
Since vim 9.1.0469, completeopt is a global-local option.
When adding
noselect
, we need to treatcompleteopt
as local and usesetlocal
.This works for 9.1.0016 as well and allows users to freely mess with buffer-local
completeopt
without messing up YCM completions.
Fixes #4261
This change is