You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
$ go env
GOOS="darwin"
GOARCH="amd64"
What did you do?
While using recommended gopls settings with latest vscode-go extension for VSCode, I'm using editor.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).
[Trace - 1:49:31 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"invalid position for file "}
[Error - 13:49:31] invalid position for file
[Trace - 1:49:31 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"invalid position for file "}
[Error - 13:49:31] invalid position for file
[Trace - 1:49:31 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"invalid position for file "}
[Error - 13:49:31] invalid position for file
[Trace - 1:49:31 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"invalid position for file "}
[Error - 13:49:31] invalid position for file
[Error - 1:49:31 PM] send textDocument/codeAction#18 no file information for file:///Users/idanilkin/Go/src/golang.org/x/tools/internal/span/span.go
[Error - 13:49:31] Request textDocument/codeAction failed.
Message: no file information for file:///Users/idanilkin/Go/src/golang.org/x/tools/internal/span/span.go
Code: 0
[Trace - 1:49:32 PM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"invalid position for file "}
[Error - 13:49:32] invalid position for file
[Error - 1:49:32 PM] send textDocument/documentSymbol#19 no file information for file:///Users/idanilkin/Go/src/golang.org/x/tools/internal/span/span.go
[Error - 13:49:32] Request textDocument/documentSymbol failed.
Message: no file information for file:///Users/idanilkin/Go/src/golang.org/x/tools/internal/span/span.go
Code: 0
The text was updated successfully, but these errors were encountered:
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.
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 #31797 introduced this behavior.
More particularly, this commit: golang/tools@9cb3dcf
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
traceThe text was updated successfully, but these errors were encountered: