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: off by one error in name function rename #39364

Closed
WBare opened this issue Jun 2, 2020 · 5 comments
Closed

x/tools/gopls: off by one error in name function rename #39364

WBare opened this issue Jun 2, 2020 · 5 comments
Labels
FrozenDueToAge 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

@WBare
Copy link

WBare commented Jun 2, 2020

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go
    • go version go1.14.3 windows/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
    • Version: 1.45.1 (system setup)
      Commit: 5763d909d5f12fe19f215cbfdd29a91c0fa9208a
      Date: 2020-05-14T08:27:35.169Z
      Electron: 7.2.4
      Chrome: 78.0.3904.130
      Node.js: 12.8.1
      V8: 7.8.279.23-electron.0
      OS: Windows_NT x64 10.0.18363
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.14.3

Describe the bug

When changing a function name which is preceded by a multiline /* */ style doc comment, the name change makes two mistakes.

  1. it moves the function name within the comment from the line immediately after the starting /* up one line and touching the starting /*
  2. it leaves the last character from the old name appended to the end of the new name.

Maybe it is somehow related to two char Windows end of line CR/LF.

Steps to reproduce the behavior:

Add this code to a .go file:

/*
Test description
*/
func Test() {
    return
}

Now place your cursor in the function name Test() and press F2 to change the name. Type the new name Gronk. The result will be:

/*Gronkt description
*/
func Gronk() {
    return
}
@hyangah
Copy link
Contributor

hyangah commented Jun 2, 2020

@WBare Can you please share your go related settings? (those starting with go or [go] or gopls). We need it to figure out what tool is doing the renaming job.

If you are using the language server ("go.useLanguageServer": true), please follow the instruction in https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#vs-code and share the gopls log. Thanks!

@WBare
Copy link
Author

WBare commented Jun 2, 2020

Ok. Here are the settings:

{
"files.autoSave": "afterDelay",
"workbench.statusBar.feedback.visible": false,
"git.autofetch": true,
"git.enableSmartCommit": true,
"git.confirmSync": false,
"diffEditor.renderSideBySide": false,
"todo-tree.highlights.enabled": true,
"explorer.confirmDelete": false,
"python.jediEnabled": false,
"go.formatTool": "goimports",
"todo-tree.tree.showScanModeButton": false,
"terminal.integrated.scrollback": 5000,
"cSpell.userWords": [
"Equalf",
"bbolt",
"bitstream",
"hashicorp",
"neuroics",
"ntsd",
"protobuf",
"stuct",
"unbuffered",
"unmarshaled",
"unmarshalling"
],
"cSpell.dictionaryDefinitions": [

],
"go.useLanguageServer": true

}

And here is the View->Output -> gopls

[Info - 1:35:01 PM] 2020/06/02 13:35:01 Build info

golang.org/x/tools/gopls 0.4.1
golang.org/x/tools/gopls@v0.4.1 h1:0e3BPxGV4B3cd0zdMuccwW72SgmHp92lAjOyxX/ScAw=
github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
golang.org/x/mod@v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
golang.org/x/tools@v0.0.0-20200513154647-78b527d18275 h1:e7nYe9s94RHunFJ7b+mmPxiQMOKMVSqYASToWb1EcHs=
golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
honnef.co/go/tools@v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=
mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=

Go info

go version go1.14.3 windows/amd64

[Info - 1:35:02 PM] 2020/06/02 13:35:02 go env for D:\GoDev\neuroics.com
(valid build configuration = true)
(build flags: [-modfile=C:\Users\WARREN2\AppData\Local\Temp\go.neuroics.com.168455767.mod])
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Warren Bare\AppData\Local\go-build
set GOENV=C:\Users\Warren Bare\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Warren Bare\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=D:\GoDev\neuroics.com\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\WARREN~2\AppData\Local\Temp\go-build973149906=/tmp/go-build -gno-record-gcc-switches

[Info - 1:35:02 PM] 2020/06/02 13:35:02 go/packages.Load
snapshot=0
directory=D:\GoDev\neuroics.com
query=[./... builtin]
packages=47

[Info - 1:35:33 PM] 2020/06/02 13:35:33 background imports cache refresh starting

[Info - 1:35:33 PM] 2020/06/02 13:35:33 background refresh finished after 302.2648ms

@stamblerre
Copy link
Contributor

Thank you! Looks like you're using gopls so I will transfer this to the gopls issue tracker.

@stamblerre stamblerre transferred this issue from golang/vscode-go Jun 2, 2020
@stamblerre stamblerre changed the title Off by one error in name function name change x/tools/gopls: off by one error in name function rename Jun 2, 2020
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jun 2, 2020
@gopherbot gopherbot added this to the Unreleased milestone Jun 2, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.5.0 Jun 2, 2020
@golang golang deleted a comment from gopherbot Jul 2, 2020
@stamblerre
Copy link
Contributor

Thanks for the report @WBare. You are right to say that this relates to Windows line endings. I'll take a look at this and see if it's fixable, but in the meantime, we do suggest always using Unix line endings, as gofmt always uses them.

@gopherbot
Copy link

Change https://golang.org/cl/240757 mentions this issue: internal/lsp: fix rename with Windows line endings

@stamblerre stamblerre modified the milestones: gopls/v0.5.0, gopls/v0.4.4 Jul 12, 2020
@golang golang locked and limited conversation to collaborators Jul 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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

4 participants