Skip to content

Fix LSP symbol lookup failing due to skipping a character #107865

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mphe
Copy link
Contributor

@mphe mphe commented Jun 22, 2025

This bug occurs when resolving a completion item (completionItem/resolve) and the cursor position reported by the LSP client is at the start of the completed item.

In that case get_text_for_lookup_symbol() will skip the character the cursor is placed on, thus never finds a string matching the given symbol name and causes the lookup to fail. This in turn prevents documentation for the completed symbol from showing up.

This scenario may occur with clients that have completion auto-insertion enabled, i.e. selecting a completion inserts it immediately.
In that scenario, the cursor position is technically at the first character of the completed item until the user starts typing again, implicitly accepting the completion.

It seemed like only functions were affected by this bug. Constants and members seemed to work fine.

Example (cursor position is indicated by |):

node.|
# Now the completion list appears and we cycle through and select add_child()

# Visual cursor position is at the end, but reported cursor position is at the beginning
node.a|dd_child(

This bug occurs when resolving a completion item (completionItem/resolve) and the cursor position
reported by the client is at the start of the completed item.

In that case get_text_for_lookup_symbol() will skip the character the cursor is placed on, thus
never finds a string matching the given symbol name and causes the lookup to fail.
This in turn prevents documentation for the completed symbol from showing up.

This scenario may occur with clients that have completion auto-insertion enabled, i.e. selecting a
completion inserts it immediately.
In that scenario, the cursor position is technically at the first character of the completed item
until the user starts typing again, implicitly accepting the completion.
@mphe mphe requested a review from a team as a code owner June 22, 2025 21:06
@dalexeev dalexeev added this to the 4.5 milestone Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants