x/tools/gopls: rename applies duplicate edits to a file with aliases (symlinks) #59550
Labels
gopls
Issues related to the Go language server, gopls.
NeedsFix
The path to resolution is known, but the work has not been done.
Refactoring
Issues related to refactoring tools
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
The kubernetes repo has multiple submodules (
k8s.io/xyz
), each with a replace directive in the main module that maps them to./staging/xyz
. Thevendor
directory contains symbolic linksvendor/xyz
to../staging/xyz
. This means files and directories in staging have aliases suchvendor/k8s.io/kubectl -> ../../staging/src/k8s.io/kubectl
.I have observed that some gopls renamings cause the same edits to be applied to both aliases of the same file. If the renaming is length-preserving, this is harmless, but otherwise a renaming from A to AB results in ABB, with a repeated suffix. (Presuambly a renaming that shortened would be even more destructive.)
We need to merge edits not just based on URI equivalence (as we do already), but based on the file system's notion of equivalence, using os.SameFile or robustio.FileID.
(See also https://go.dev/cl/457615, which did the same thing for the go/analysis -fix logic.)
The text was updated successfully, but these errors were encountered: