Skip to content

Conversation

ZaharChernenko
Copy link

@ZaharChernenko ZaharChernenko commented Apr 9, 2025

PR Prelude

  • I have read and understood YCM's [CONTRIBUTING][cont] document.
  • I have read and understood YCM's [CODE_OF_CONDUCT][code] 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

The function s:ShowHoverResult() assumes b:ycm_hover always exists when processing hover responses. However, this assumption is unsafe, and leads to errors like this:

Error detected while processing function <SNR>151_PollCommands[30]..<SNR>151_ShowHoverResult:
line   36:
E121: Undefined variable: b:ycm_hover
Error detected while processing function <SNR>151_PollCommands[30]..<SNR>151_ShowHoverResult:
line   36:
E116: Invalid arguments for function has_key( b:ycm_hover, 'popup_params' )
Error detected while processing function <SNR>151_PollCommands[30]..<SNR>151_ShowHoverResult:
line   42:
E121: Undefined variable: b:ycm_hover
Error detected while processing function <SNR>151_PollCommands[30]..<SNR>151_ShowHoverResult:
line   42:
E116: Invalid arguments for function setbufvar

So I added a check for the existence of a variable.


This change is Reviewable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant