Skip to content

References are opened under realpath and not the workspace path #870

@ungive

Description

@ungive

I have my project located under /foo/bar/project and I opened a workspace for it under /bar/project where /bar is a symlink to /foo/bar. This means I'm accessing my workspace "through a symlink" so to speak, instead of the real path.

Now, when I click on "Go to definition" of a symbol in a C++ file in this opened workspace, the file in which that symbol is defined will be opened outside of my workspace because e.g. the file /foo/bar/project/file.cpp is opened instead of /bar/project/file.cpp and VSCodium cannot properly associate it with the workspace because the two paths do not share the same parent (/foo/bar and /bar). This causes all sorts of problems.

I think the clangd extension should recognize when the project is opened under a symlink (/bar/project) and adjust the path of an opened file (/foo/bar/project/file.cpp) to the correct path in the workspace (/bar/project/file.cpp), if the two paths point to the same file, i.e. realpath is identical for the two.

Maybe there's an issue with the extension where the realpath is resolved in a place where it shouldn't. My compile_commands.json contains the correct paths (/bar/...), so that can't be the reason why the file is opened under /foo/bar/....

I hope I explained it well! For now I will open my workspace under /foo/bar instead.

System information
Clangd version: 20.1.8
clangd extension version: 0.2.0
Operating system: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions