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.41k stars 320 forks source link

Incorrect results about Go-to-definition and Go-to-declaration #1486

Closed tisble closed 1 month ago

tisble commented 1 month ago

Link: https://github.com/clangd/vscode-clangd/issues/634

Hi, I found a bug about the go to definition and go to declaration when used clangd in vscode. Please see the code example below:

#include  <stdio.h>
struct str {
    int v;
};
int main() {
    str s;
    s.v = 10;
    return 0;
}

I performed Go-to-def/decl on the variable s in declaration statement at line 6, but it jumps to the variable s at line 7. Actually, I think this is Go to Use or Find References, rather than Go-to-def or decl (should be unchanged at line 6). So, this is a bug.

System information

Clangd version: Apple clangd version 15.0.0 (clang-1500.3.9.4) Features: mac+xpc Platform: x86_64-apple-darwin23.5.0; target=arm64-apple-darwin23.5.0

clangd extension version: Version 0.1.28: March 20, 2024

Operating system: MacOS

dbaeumer commented 1 month ago

See the answer here: https://github.com/clangd/vscode-clangd/issues/634#issuecomment-2130749041

This is expected VS Code behavior. I will close the issue.