Closed nezorflame closed 5 years ago
I believe that range formatting is totally broken right now (the call textDocument/rangeFormatting) which is used by formatOnPaste. I don't think this has anything to do with that commit, it has just never worked. I know Rebecca was looking into it. All other formatting uses full file formatting.
I also have this problem with the latest commit, just rolled back gopls and copy pasting is working.
Seems that the latest commits fixed this behaviour.
What version of Go are you using (
go version
)?gopls
commit hashDoes 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?
While using recommended
gopls
settings with latest vscode-go extension for VSCode, I'm usingeditor.formatOnPaste
setting to format the code on Paste action. Now when I paste the code, the whole file contents get removed (except for the inserted part).Example: https://www.giphy.com/gifs/XHFt4o5jQOGIkOPKqo
What did you expect to see?
Code should be formatted, without removal.
What did you see instead?
Complete code removal (except for the inserted code).
Problem analysis
It seems that the fix for the issue https://github.com/golang/go/issues/31797 introduced this behavior. More particularly, this commit: https://github.com/golang/tools/commit/9cb3dcf692a103de0fd68c26f4f04183e0933f7c
Example previously shown in GIF shows the problem at the
internal/span/span.go:252
where the wordhasPosition
gets copied and pasted.Here's the trace after the Paste action:
gopls
trace