microsoft / vscode-languageserver-node

Language server protocol implementation for VSCode. This allows implementing language services in JS/TS running on node.js
MIT License
1.45k stars 325 forks source link

`textDocument/definition` does not work if cursor is inside `targetSelectionRange` #1530

Closed abhi40308 closed 1 month ago

abhi40308 commented 1 month ago

Description

This might be a vscode issue, just wanted to ask any workarounds or am I missing something here. I wasn't able to find any similar issue filed anywhere.

I have a textDocument/definition request as such:

[
    {
        "targetUri": "file:///Users/xyz/Downloads/jul24/my_subgraph/metadata/CartItems.hml",
        "targetRange": {
            "start": {
                "line": 0,
                "character": 0
            },
            "end": {
                "line": 11,
                "character": 15
            }
        },
        "targetSelectionRange": {
            "start": {
                "line": 0,
                "character": 0
            },
            "end": {
                "line": 11,
                "character": 15
            }
        },
        "originSelectionRange": {
            "start": {
                "line": 11,
                "character": 12
            },
            "end": {
                "line": 12,
                "character": 0
            }
        }
    }
]

Notice the targetSelectionRange is upto L11C15. When cursor is at L11C16 or C >= 16 the text definition request (Cmd + click) highlights the document correctly, but if I place cursor C <= 15 the definition request returns No references found for ...

Posting recording, here I have hardcoded the targetSelectionRange and targetRange to the above mentioned values, and I try with multiple cursor positions, when the cursor is within the targetSelectionRange Go-to-definition does not work, although the textDocument/definition response is being sent correctly to the vscode client from the debug logs (not shown in video):

https://github.com/user-attachments/assets/043e6673-461e-44ad-9d64-a618f3dc9e6f

"vscode-languageserver": "9.0.1",
"vscode-languageclient": "9.0.1",
He1pa commented 1 month ago

it just a default setting in vscode, you can disable it image

abhi40308 commented 1 month ago

thanks this resolves it! closing the issue