Skip to content

Symbolic link directories interfere with go-to-definition and find-all-references functionality #2059

@ahelwer

Description

@ahelwer

Like many Linux users, several subdirectories of my $HOME are symbolic links to directories that live on a separate data partition. This is used to keep a consistent workspace across distros. This also means that every file in my OCaml project has two separate paths which alias to the same file; for example:

  • ~/src/tlaplus/proofs/src/tlapm_lib.ml
  • /mnt/data/src/tlaplus/proofs/src/tlapm_lib.ml

A good correctness criterion here is that all paths should resolve to ~/ paths instead of /mnt paths if operating from a ~/ context, which is what VS Code does when opening files when launched inside the ~/ path. Resolving a path to a /mnt/ path generally results in buggy behavior, which I will document here.

This extension generally works well, except for two cases I've found: go-to-definition, and find-all-references. These work for OCaml files within the same subdirectory, but fails when going outside of that subdirectory. Consider the following project structure, which will be used to explain the problem:

/
└── src/
    ├── tlapm_lib.ml
    └── sany/
        ├── sany.ml
        └── xml.ml

Go-to-definition

When executing go-to-definition on a symbol defined in xml.ml from sany.ml, go-to-definition works perfectly: xml.ml is opened at the appropriate definition, using a ~/ prefix. However, when executing go-to-definition on a symbol defined in sany/sany.ml from tlapm_lib.ml, sany.ml is opened with the /mnt prefix. This is arguably not inherently a bug, although other plugins (for example, neovim) find it confusing to have multiple buffers open that alias to the same file.

Find-all-references

For ~/ prefixes, find-all-references only works for files within the same subdirectory. When executing find-all-references on a definition in xml.ml, it will correctly find the uses within sany.ml. However, when executing find-all-references on a definition in sany.ml, it will not find the uses within tlapm_lib.ml. This is definitely a bug.

When sany.ml is opened with the /mnt prefix (for example by running go-to-definition from tlapm_lib.ml), running find-all-references on the same symbol in sany.ml correctly finds the usage in tlapm_lib.ml.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ocaml-lspupstreamIssues that need to be addressed in upstream projects

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions