Skip to content
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

Merged
merged 1 commit into from
Sep 14, 2024

Conversation

bstaletic
Copy link
Collaborator

@bstaletic bstaletic commented Sep 13, 2024

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:

  • I have read and understood YCM's CONTRIBUTING document.
  • I have read and understood YCM's CODE_OF_CONDUCT document.
  • I have included tests for the changes in my PR. If not, I have included a
    rationale for why I haven't.
  • 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

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.

Fixes #4261


This change is Reviewable

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.
Copy link

codecov bot commented Sep 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.80%. Comparing base (80728a1) to head (d517711).
Report is 2 commits behind head on master.

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
Copy link
Member

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

Copy link
Collaborator Author

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:

  1. Do some completion thing, so that we mess with buffer-local completeopt.
  2. Manually mess with the global value. At the point, the buffer-local completeopt is destroyed, because global config changed.
  3. 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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. SGTM.

@puremourning
Copy link
Member

puremourning commented Sep 14, 2024

:lgtm:

@bstaletic bstaletic added the Ship It! Manual override to merge a PR by maintainer label Sep 14, 2024
Copy link
Contributor

mergify bot commented Sep 14, 2024

Thanks for sending a PR!

@mergify mergify bot merged commit 63ab13e into ycm-core:master Sep 14, 2024
12 checks passed
@bstaletic bstaletic deleted the buffer-local-completeopt branch September 14, 2024 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ship It! Manual override to merge a PR by maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Possible regression with setlocal autocomplete-=preview for vim-9.1.0496 and above (since June 17th)
2 participants