vscode-clangd
vscode-clangd copied to clipboard
Find all references is jumbled by any file changes
https://youtu.be/kvjtP-kBHqg
When adding any new lines or code to a file, it will completely scramble my clangd find-all-reference results. The only way to recover that I've found is to restart the language server. This has been happening to me for the last few months.
This happens in any codebase I use, no matter it be at home or at work. I've tried different llvm versions, I've tried the pre-release extension, I've tried different CMake versions (for different compile_commands.json maybe?) but to no avail.
Logs
System information clangd version 18.1.8 Features: windows Platform: x86_64-pc-windows-msvc
clangd extension version: 0.1.33 or 0.1.34
Operating system: Windows 11 Home
I've tried to reproduce this, in both a large project I work on, and a minimal project created for the purpose, but I have not been able to so far.
Would you be able to share a (preferably minimal) example project in which this occurs, so I can be sure I'm trying the same thing as you are?
Good morning @HighCommander4! I am not sure if there may be something messed up with my environment, but it's strange because it happens both on my home PC as well as my work PC. So if it is my environment or clangd installation, I must have managed to do the same bad thing on both setups.
Is there something I can do to ensure that the clangd that vscode is using is what was reported in the log I sent? And is that what you're using to reproduce?
https://github.com/user-attachments/assets/d41ec83c-04d2-45fd-8ba9-077d05424ead
I want to note that although I have llvm installed globally (available in PATH) vscode/the extension appears to have installed its own version of clangd, as it reports 19.1.2 in the log I sent before. I would hope this isn't an issue, just something interesting to note.
I also have tried uninstalling all my other vscode extensions, but the exact same issue persists.
@gaberundlett-tuxedo Sorry I haven't had a chance to try out your test project yet.
However, I do see that you're on Windows, and we've recently had a report of a very similar issue on Windows, https://github.com/clangd/vscode-clangd/issues/819, which turned out to be due to case insensitivity, and which was resolved by the workaround discussed here. It could be worth giving that same workaround a try (if applicable), to see if it helps in your case as well.
Hi @HighCommander4. I tried renaming all C:/ in my compile commands.json to c:/, and it worked! So yes that case sensitivity issue is the issue I'm facing.
I think the real solution would be for clangd to fix this upstream, but it doesn't look like that's happening any time soon.. 😔
Do you know if there is a good way to get the generated compile commands to have lowercase drive letters with cmake automatically? or must I do this manually every time it's regenerated...
Do you know if there is a good way to get the generated compile commands to have lowercase drive letters with cmake automatically?
Maybe a post-build step that runs a sed command (or whatever the analogue of sed is in Windows, something in PowerShell perhaps) on the compile_commands.json file?