Open aleun opened 3 years ago
Hey @aleun, thanks for the detailed repro steps and logs! It seems that the browsePath
is not being set correctly in your second set of logs and the result is that the source file you're trying to navigate to has not been processed by cpptools yet so it is unaware of the definition.
The disappointing part is that I am unable to repro this under a debugger. The first time I loaded your project in VS Code I was able to reproduce the empty browsePath
, but after debugging and reloading the project without a debugger attached, I no longer have a repro (even when I delete my cached configuration and reconfigure). Is this 100% repro for you?
I just tried opening and closing the project multiple times, with and without deleting the cache.
It repros 100% for me on first opening the project with no cache.
However, I have noticed that if I reopen the project without clearing the cache, after some non-deterministic number of attempts to navigate, it will eventually go to the correct definition. I managed to capture this behavior. In the video, I delete the cache, reload, navigate to definition several times (all times go to foo.h
). Then I reload, navigate to definition several times again (the final attempt goes to foo.c
).
Attempting to do the goto definition quickly after loading the folder will be met with some non-determinism as the language server starts up and figures out if paths have changed, etc. When all of that settles (e.g. fire and DB icons are gone from the status bar), then you can be sure that the extension is fully loaded and ready. I'm unable to see the full status bar in your GIF, so I don't know. The most important part is what you see in the Log Diagnostics output.
Attempting to do the goto definition quickly after loading the folder will be met with some non-determinism as the language server starts up and figures out if paths have changed, etc. When all of that settles (e.g. fire and DB icons are gone from the status bar), then you can be sure that the extension is fully loaded and ready.
I just tried again and made sure the fire and DB icons were gone. I'm seeing the same behavior consistently: if it's the first project load with no cache, then the browsePath
is empty, but on subsequent reload, the browsePath
contains the expected paths.
For me I am able to reproduce 100% of the time. Haven't tried to clear the logs. But i shutdown, open again, even restart system, it is 100% reproducible. Uninstalled cmake tools, restart vscode, no longer reproducible.
Brief Issue Summary
When using
vscode-cpptools
version 1.6.0, Go to Definition on a function callsite goes to the header declaration instead of its implementation after upgradingvscode-cmake-tools
from 1.7.3 to 1.8.1.I am not sure if this issue belongs in this repo or
vscode-cpptools
, but let's start here.I have a minimal embedded C project that I'm able to repro consistently against: https://github.com/aleun/cmake-cpp-repro. It is self-contained and includes the ARM GCC, CMake, and Ninja Windows binaries I used.
Expected:
nxp
directory:code nxp
main.c
run_foo
run_foo
definition infoo.c
.Apparent Behavior:
nxp
directory:code nxp
main.c
run_foo
run_foo
infoo.h
, notfoo.c
.C/C++: Log Diagnostics Output
Here are the log outputs for both 1.7.3 and 1.8.1.
browsePath
is empty in the latter.CMake Tools 1.7.3
CMake Tools 1.8.1
Platform and Versions
arm-none-eabi-gcc.exe (GNU Arm Embedded Toolchain 10-2020-q4-major) 10.2.1 20201103 (release)