Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: fillStruct mess-up code format #70690

Open
echoface opened this issue Dec 5, 2024 · 4 comments
Open

x/tools/gopls: fillStruct mess-up code format #70690

echoface opened this issue Dec 5, 2024 · 4 comments
Assignees
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@echoface
Copy link

echoface commented Dec 5, 2024

gopls version

v0.16.2

go env

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/xxx/Library/Caches/go-build'
GOENV='/Users/xxx/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/xxxx/go/pkg/mod'
GOOS='darwin'
GOPATH='/Users/xxx/go'
GOROOT='/opt/homebrew/Cellar/go/1.23.2/libexec'
GOSUMDB='sum.golang.google.cn'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.23.2/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.2'
GODEBUG=''
GOTELEMETRY='local'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/z0/svszlpj10dj930l0y9yn9k3h0000gn/T/go-build1883146030=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

run code action:
refactor.rewrite

What did you see happen?

image
image

What did you expect to see?

image

Editor and settings

nvim builtin lsp

Logs

No response

@echoface echoface added gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Dec 5, 2024
@gopherbot gopherbot added this to the Unreleased milestone Dec 5, 2024
@echoface echoface changed the title x/tools/gopls: issue title x/tools/gopls: fillStruct mess-up code format Dec 5, 2024
@echoface
Copy link
Author

echoface commented Dec 5, 2024

[DEBUG][2024-12-05 14:16:08] .../vim/lsp/rpc.lua:408	"rpc.receive"	{  id = 16,  jsonrpc = "2.0",  result = {    data = {      arguments = { {          Fix = "fillstruct",          Range = {            ["end"] = {              character = 2,              line = 22            },            start = {              character = 9,              line = 16            }          },          ResolveEdits = true,          URI = "file:///Users/bytedance/echoface/playground/go/main.go"        } },      command = "gopls.apply_fix",      title = "Fill AAA"    },    edit = {      documentChanges = { {          edits = { {              newText = "AAA{\n\t\tNodes: []*Node{{Value: 0}, {Value: 0}},\n\t\tEdges: map[*Node]*Node{},\n\t}",              range = {                ["end"] = {                  character = 2,                  line = 22                },                start = {                  character = 9,                  line = 16                }              }            } },          textDocument = {            uri = "file:///Users/bytedance/echoface/playground/go/main.go",            version = 7          }        } }    },    kind = "refactor.rewrite",    title = "Fill AAA"  }}

pretty response

local x = {
    id = 16,
    jsonrpc = "2.0",
    result = {
        data = {
            arguments = {
                {
                    Fix = "fillstruct",
                    Range = { ["end"] = {
                            character = 2,
                            line = 22
                        },
                        start = {
                            character = 9,
                            line = 16
                        }
                    },
                    ResolveEdits = true,
                    URI = "file:///Users/xxx/echoface/playground/go/main.go"
                }
            },
            command = "gopls.apply_fix",
            title = "Fill AAA"
        },
        edit = {
            documentChanges = {
                {
                    edits = {
                        {
                            newText = "AAA{\n\t\tNodes: []*Node{{Value: 0}, {Value: 0}},\n\t\tEdges: map[*Node]*Node{},\n\t}",
                            range = { ["end"] = {
                                    character = 2,
                                    line = 22
                                },
                                start = {
                                    character = 9,
                                    line = 16
                                }
                            }
                        }
                    },
                    textDocument = {
                        uri = "file:///Users/xxx/echoface/playground/go/main.go",
                        version = 7
                    }
                }
            }
        },
        kind = "refactor.rewrite",
        title = "Fill AAA"
    }
}

@findleyr
Copy link
Member

findleyr commented Dec 5, 2024

To be clear: the ask here is to preserve the existing formatting of node fields, right?

My guess is that we reformat the entire node with no position information. In that case, I think this should be straightforward to fix.

@findleyr findleyr modified the milestones: Unreleased, gopls/v0.18.0 Dec 5, 2024
@echoface
Copy link
Author

echoface commented Dec 6, 2024

To be clear: the ask here is to preserve the existing formatting of node fields, right?

My guess is that we reformat the entire node with no position information. In that case, I think this should be straightforward to fix.

"To be clear: the ask here is to preserve the existing formatting of node fields, right?"

  • yes, gopls join element Nodes into oneline now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants