When multiple files (here .cpp files) are present and are mentioned in the compile_commands.json file, the `go-to-definition´ will jump into files with objects with equal name (tested here with classes), even though they are completely separate.
Minimal testcase
create a directory called test_case with the following files:
Compile with cmake . to get the compile_commands.json.
Expected behavior
When jumping from A a via the go to definition, I would expect it to only jump to the above declaration of the class. However for me (using neovim + native LSP), it opens a quickfix list with both files. Clangd on the other hand only jumps to the declaration in the same file (in my opinion the expected behaviour).
Deleting the entry with file2 in the compile_commands.json gives the expected behaviour.
Observed behavior
When multiple files (here .cpp files) are present and are mentioned in the
compile_commands.json
file, the `go-to-definition´ will jump into files with objects with equal name (tested here with classes), even though they are completely separate.Minimal testcase
create a directory called
test_case
with the following files:CMakeLists.txt
file1.cpp
file2.cpp
Compile with
cmake .
to get thecompile_commands.json
.Expected behavior
When jumping from
A a
via thego to definition
, I would expect it to only jump to the above declaration of the class. However for me (using neovim + native LSP), it opens a quickfix list with both files. Clangd on the other hand only jumps to the declaration in the same file (in my opinion the expected behaviour).Deleting the entry with
file2
in thecompile_commands.json
gives the expected behaviour.System information