Open myitcv opened 3 years ago
If I'm hovering over the field selector x.T, and rename T, it is surprising that this would end up renaming a type.
^from the CL associated with #43616.
I think I agree with that statement but even I find myself doing this quite often and would love for :GoRename to support this. Could there be a middle ground? for instance, only allowing rename if the field(type) is part of the same package and throw an error otherwise?
for instance, only allowing rename if the field(type) is part of the same package and throw an error otherwise?
That seems a little arbitrary.
I think the feature seems reasonable as requested. It's analogous to the way the tool handles renaming of methods: if you rename a concrete method so that it would no longer satisfy an interface, you can an error; but if you rename the interface method, this is taken as intent to change all implementations too.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Follow up from https://github.com/golang/go/issues/43616#issuecomment-759058419 (cc @mdempsky)
Relatively frequently I find myself in the following situation:
With the cursor on the embedded
T
inS
.I then initiate a rename, but get:
The fix in this instance is to jump to the definition of
T
, rename, then jump back. But obviouslygopls
can do that 😄To my mind this case is distinct from the case of selector expressions mentioned in https://github.com/golang/go/issues/43616#issuecomment-759058419: such a situation is more ambiguous because we can't be sure the user knows the field in question is an embedded field.
But in this case our cursor is on the declaration of the embedded field, so there can be no ambiguity.
cc @findleyr
FYI @leitzler