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: comments duplicated with CRLF files #42923

Closed
fonini opened this issue Dec 1, 2020 · 8 comments
Closed

x/tools/gopls: comments duplicated with CRLF files #42923

fonini opened this issue Dec 1, 2020 · 8 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

@fonini
Copy link

fonini commented Dec 1, 2020

What version of Go are you using (go version)?

$ go version
go version go1.15.5 windows/amd64

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
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\User\AppData\Local\go-build
set GOENV=C:\Users\User\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\projetos\pkg\mod
set GOOS=windows
set GOPATH=C:\projetos\
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=C:\projetos\src\test-api\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\User\AppData\Local\Temp\go-build232461266=/tmp/go-build -gno-record-gcc-switches

What did you do?

I'm using VSCode with the latest gopls (0.5.4).
When I save a Go file in the VScode editor (Windows with CRLF), the comment section is getting duplicated.

Alt text

What did you expect to see?

The file to be saved correctly.

What did you see instead?

The comment section being duplicated.

@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 Dec 1, 2020
@gopherbot gopherbot added this to the Unreleased milestone Dec 1, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.6.0 Dec 1, 2020
@stamblerre stamblerre added this to Needs Triage in vscode-go: gopls by default via automation Dec 1, 2020
@stamblerre stamblerre changed the title x/tools/gopls: Comments being duplicated when I save the file x/tools/gopls: comments duplicated with CRLF files Dec 1, 2020
@stamblerre stamblerre self-assigned this Dec 1, 2020
@tomqwpl
Copy link

tomqwpl commented Dec 2, 2020

Also see this issue. I think I upgraded the language server in the last couple of days, not sure how I tell what version I'm running.

@fonini
Copy link
Author

fonini commented Dec 2, 2020

@tomqwpl You can run gopls version

@tomqwpl
Copy link

tomqwpl commented Dec 2, 2020

Running that in a terminal window within VSCode gives:

  golang.org/x/tools/gopls v0.5.4
      golang.org/x/tools/gopls@v0.5.4 h1:PkQWDfzw8CxoseHDQniF2GhzmndN8KnQL6gcG2gnF3Y=

What I wasn't sure about was whether this was what was being used by VSCode.

@hyangah
Copy link
Contributor

hyangah commented Dec 2, 2020

@tomqwpl The easiest is to check from the UI (https://github.com/golang/vscode-go/blob/master/docs/ui.md#language-server-status). Another way is to check Go: Locate Configured Go Tools output to find the path to the gopls binary.

@tomqwpl
Copy link

tomqwpl commented Dec 2, 2020

Go: Locate Configured Go Tools produces nothing in the output, but clicking on the go version number in the status bar brings up a menu with "open gopls trace v0.5.4", so that appears to be what I have. Which makes sense, since I upgraded a couple of days ago after a prompt.

I don't always see these symptoms. And when I do, changing the comment to be a single line, rather than a multi line comment makes it go away.

For example, right now I have this:

// Config describes a common configuration block
// for a database connection
type Config struct {
	// Type is the type of database. Currently supported database types
	// are:
	//   postgres
	Type   string      `json:"type"`
	Config StoreConfig `json:"config"`
}

If I press save, the "for a database connection" line is duplicated, so I get two copies. Press save again, and the whole thing is duplicated, so I have 4 copies of that line, and so on. The first line is not duplicated.
Change that to a single line comment and the problem goes away.

@hyangah
Copy link
Contributor

hyangah commented Dec 2, 2020

I confirm this is reproducible with the latest version of gopls (v0.5.4)

gopls log ``` [Trace - 10:44:19.788 AM] Received notification 'window/logMessage'. Params: {"type":3,"message":"2020/12/02 10:44:19 Shutdown session\n\tshutdown_session=1\n"}

[Trace - 10:44:19.863 AM] Sending request 'initialize - (0)'.
Params: {"processId":2052,"clientInfo":{"name":"vscode","version":"1.51.1"},"rootPath":"c:\Users\hakim\work","rootUri":"file:///c%3A/Users/hakim/work","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional"},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true,"semanticTokens":{"refreshSupport":true}},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"versionSupport":false,"tagSupport":{"valueSet":[1,2]},"codeDescriptionSupport":true,"dataSupport":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]},"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true},"activeParameterSupport":true},"contextSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true,"tagSupport":{"valueSet":[1]},"labelSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"disabledSupport":true,"dataSupport":true,"resolveSupport":{"properties":["edit"]},"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true,"prepareSupportDefaultBehavior":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"declaration":{"dynamicRegistration":true,"linkSupport":true},"selectionRange":{"dynamicRegistration":true},"callHierarchy":{"dynamicRegistration":true},"semanticTokens":{"dynamicRegistration":true,"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","member","macro","keyword","modifier","comment","string","number","regexp","operator"],"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"formats":["relative"],"requests":{"range":true,"full":{"delta":true}}}},"window":{"workDoneProgress":true}},"initializationOptions":{},"trace":"off","workspaceFolders":[{"uri":"file:///c%3A/Users/hakim/work","name":"work"}]}

[Trace - 10:44:19.863 AM] Received response 'initialize - (0)' in 0ms.
Result: {"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"save":{}},"completionProvider":{"triggerCharacters":["."]},"hoverProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"typeDefinitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","refactor.extract","refactor.rewrite","source.fixAll","source.organizeImports"]},"codeLensProvider":{},"documentLinkProvider":{},"workspaceSymbolProvider":true,"documentFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":""},"renameProvider":{"prepareProvider":true},"foldingRangeProvider":true,"executeCommandProvider":{"commands":["gopls.generate","gopls.fill_struct","gopls.regenerate_cgo","gopls.test","gopls.tidy","gopls.undeclared_name","gopls.add_dependency","gopls.upgrade_dependency","gopls.remove_dependency","gopls.vendor","gopls.extract_variable","gopls.extract_function","gopls.gc_details","gopls.generate_gopls_mod"]},"callHierarchyProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"workspace/didChangeWorkspaceFolders"}}},"serverInfo":{"name":"gopls","version":"{"path":"golang.org/x/tools/gopls","version":"v0.5.4","sum":"h1:PkQWDfzw8CxoseHDQniF2GhzmndN8KnQL6gcG2gnF3Y=","deps":[{"path":"github.com/BurntSushi/toml","version":"v0.3.1","sum":"h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ="},{"path":"github.com/google/go-cmp","version":"v0.5.1","sum":"h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k="},{"path":"github.com/sergi/go-diff","version":"v1.1.0","sum":"h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0="},{"path":"golang.org/x/mod","version":"v0.3.0","sum":"h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4="},{"path":"golang.org/x/sync","version":"v0.0.0-20201020160332-67f06af15bc9","sum":"h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck="},{"path":"golang.org/x/tools","version":"v0.0.0-20201123203206-735e963e909b","sum":"h1:U8XGResmZKfdo8rCjWPsuiB4cu7N0PJSpQwc9lZr9Rg="},{"path":"golang.org/x/xerrors","version":"v0.0.0-20200804184101-5ec99f83aff1","sum":"h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE="},{"path":"honnef.co/go/tools","version":"v0.0.1-2020.1.6","sum":"h1:W18jzjh8mfPez+AwGLxmOImucz/IFjpNlrKVnaj2YVc="},{"path":"mvdan.cc/gofumpt","version":"v0.0.0-20200927160801-5bfeb2e70dd6","sum":"h1:z+/YqapuV7VZPvBb3GYmuEJbA88M3PFUxaHilHYVCpQ="},{"path":"mvdan.cc/xurls/v2","version":"v2.2.0","sum":"h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A="}]}"}}

[Trace - 10:44:19.880 AM] Sending notification 'initialized'.
Params: {}

[Trace - 10:44:19.880 AM] Sending notification 'textDocument/didOpen'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go","languageId":"go","version":58,"text":"package main\r\n\r\n// Config describes a common configuration block\r\n// for a database connection\r\ntype Config struct {\r\n\t// Type is the type of database. Currently supported database types\r\n\t// are:\r\n\t// postgres\r\n\tType string json:\"type\"\r\n\tConfig string json:\"config\"\r\n}\r\n"}}

[Trace - 10:44:19.880 AM] Sending request 'textDocument/documentSymbol - (1)'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go"}}

[Trace - 10:44:19.880 AM] Sending request 'textDocument/codeAction - (2)'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go"},"range":{"start":{"line":3,"character":28},"end":{"line":3,"character":28}},"context":{"diagnostics":[]}}

[Trace - 10:44:19.880 AM] Sending request 'textDocument/documentLink - (3)'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go"}}

[Trace - 10:44:19.896 AM] Received request 'window/workDoneProgress/create - (1)'.
Params: {"token":"5577006791947779410"}

[Trace - 10:44:19.896 AM] Sending response 'window/workDoneProgress/create - (1)' in 0ms.
Result:

[Trace - 10:44:19.904 AM] Received notification '$/progress'.
Params: {"token":"5577006791947779410","value":{"kind":"begin","title":"Setting up workspace","message":"Loading packages..."}}

[Trace - 10:44:19.904 AM] Received request 'workspace/configuration - (2)'.
Params: {"items":[{"scopeUri":"file:///C:/Users/hakim/work","section":"gopls"}]}

[Trace - 10:44:19.904 AM] Sending response 'workspace/configuration - (2)' in 0ms.
Result: [null]

[Trace - 10:44:20.257 AM] Sending request 'textDocument/foldingRange - (4)'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go"}}

[Trace - 10:44:20.258 AM] Sending request 'textDocument/codeLens - (5)'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go"}}

[Trace - 10:44:20.259 AM] Sending request 'textDocument/codeLens - (6)'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go"}}

[Trace - 10:44:20.538 AM] Received request 'client/registerCapability - (3)'.
Params: {"registrations":[{"id":"workspace/didChangeWatchedFiles-0","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"**/*.{go,mod,sum}","kind":7}]}}]}

[Trace - 10:44:20.540 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/12/02 10:44:20 go env for C:\Users\hakim\work\n(root C:\Users\hakim\work)\n(go version go version go1.15.5 windows/amd64)\n(valid build configuration = true)\n(build flags: [])\nGOSUMDB=sum.golang.org\nGOFLAGS=\nGONOPROXY=\nGOINSECURE=\nGOMOD=C:\Users\hakim\work\go.mod\nGOPROXY=https://proxy.golang.org,direct\nGO111MODULE=\nGOCACHE=C:\\Users\\Administrator\\AppData\\Local\\go-build\nGOPATH=C:\\Users\\Administrator\\go\nGOPRIVATE=\nGOMODCACHE=C:\\Users\\Administrator\\go\\pkg\\mod\nGONOSUMDB=\nGOROOT=c:\\go\n\n"}

[Info - 10:44:20 AM] 2020/12/02 10:44:20 go env for C:\Users\hakim\work
(root C:\Users\hakim\work)
(go version go version go1.15.5 windows/amd64)
(valid build configuration = true)
(build flags: [])
GOSUMDB=sum.golang.org
GOFLAGS=
GONOPROXY=
GOINSECURE=
GOMOD=C:\Users\hakim\work\go.mod
GOPROXY=https://proxy.golang.org,direct
GO111MODULE=
GOCACHE=C:\Users\Administrator\AppData\Local\go-build
GOPATH=C:\Users\Administrator\go
GOPRIVATE=
GOMODCACHE=C:\Users\Administrator\go\pkg\mod
GONOSUMDB=
GOROOT=c:\go

[Trace - 10:44:20.756 AM] Sending response 'client/registerCapability - (3)' in 217ms.
Result:

[Trace - 10:44:20.758 AM] Received request 'client/registerCapability - (4)'.
Params: {"registrations":[{"id":"workspace/didChangeConfiguration","method":"workspace/didChangeConfiguration"},{"id":"workspace/didChangeWorkspaceFolders","method":"workspace/didChangeWorkspaceFolders"}]}

[Trace - 10:44:20.868 AM] Sending response 'client/registerCapability - (4)' in 110ms.
Result:

[Trace - 10:44:21.125 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/12/02 10:44:21 go/packages.Load\n\tsnapshot=0\n\tdirectory=C:\Users\hakim\work\n\tquery=[builtin work/...]\n\tpackages=2\n"}

[Info - 10:44:21 AM] 2020/12/02 10:44:21 go/packages.Load
snapshot=0
directory=C:\Users\hakim\work
query=[builtin work/...]
packages=2

[Trace - 10:44:21.128 AM] Received notification '$/progress'.
Params: {"token":"5577006791947779410","value":{"kind":"end","message":"Finished loading packages."}}

[Trace - 10:44:21.131 AM] Received response 'textDocument/documentSymbol - (1)' in 1251ms.
Result: [{"name":"Config","detail":"struct{...}","kind":23,"range":{"start":{"line":4,"character":5},"end":{"line":10,"character":1}},"selectionRange":{"start":{"line":4,"character":5},"end":{"line":4,"character":11}},"children":[{"name":"Type","detail":"string","kind":8,"range":{"start":{"line":8,"character":1},"end":{"line":8,"character":28}},"selectionRange":{"start":{"line":8,"character":1},"end":{"line":8,"character":5}}},{"name":"Config","detail":"string","kind":8,"range":{"start":{"line":9,"character":1},"end":{"line":9,"character":30}},"selectionRange":{"start":{"line":9,"character":1},"end":{"line":9,"character":7}}}]}]

[Trace - 10:44:21.252 AM] Received response 'textDocument/codeAction - (2)' in 1372ms.
Result: [{"title":"Organize Imports","kind":"source.organizeImports","disabled":{"reason":""},"edit":{"documentChanges":[{"textDocument":{"version":58,"uri":"file:///C:/Users/hakim/work/main.go"},"edits":[{"range":{"start":{"line":0,"character":12},"end":{"line":0,"character":13}},"newText":""},{"range":{"start":{"line":1,"character":0},"end":{"line":1,"character":1}},"newText":""},{"range":{"start":{"line":2,"character":48},"end":{"line":2,"character":49}},"newText":""},{"range":{"start":{"line":2,"character":49},"end":{"line":2,"character":49}},"newText":"\n// for a database connection"}]}]}}]

[Trace - 10:44:21.294 AM] Received response 'textDocument/documentLink - (3)' in 1414ms.
Result: null

[Trace - 10:44:21.298 AM] Received response 'textDocument/foldingRange - (4)' in 1040ms.
Result: [{"startLine":2,"startCharacter":48,"endLine":3,"endCharacter":28,"kind":"comment"},{"startLine":4,"startCharacter":20,"endLine":9,"endCharacter":30},{"startLine":5,"startCharacter":68,"endLine":7,"endCharacter":14,"kind":"comment"}]

[Trace - 10:44:21.317 AM] Received response 'textDocument/codeLens - (5)' in 1058ms.
Result: null

[Trace - 10:44:21.318 AM] Received response 'textDocument/codeLens - (6)' in 1059ms.
Result: null

[Trace - 10:44:23.368 AM] Sending request 'textDocument/documentHighlight - (7)'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go"},"position":{"line":5,"character":46}}

[Trace - 10:44:23.371 AM] Received response 'textDocument/documentHighlight - (7)' in 2ms.
Result: []

[Trace - 10:44:23.589 AM] Sending request 'textDocument/codeAction - (8)'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go"},"range":{"start":{"line":5,"character":46},"end":{"line":5,"character":46}},"context":{"diagnostics":[]}}

[Trace - 10:44:23.594 AM] Received response 'textDocument/codeAction - (8)' in 5ms.
Result: [{"title":"Organize Imports","kind":"source.organizeImports","disabled":{"reason":""},"edit":{"documentChanges":[{"textDocument":{"version":58,"uri":"file:///C:/Users/hakim/work/main.go"},"edits":[{"range":{"start":{"line":0,"character":12},"end":{"line":0,"character":13}},"newText":""},{"range":{"start":{"line":1,"character":0},"end":{"line":1,"character":1}},"newText":""},{"range":{"start":{"line":2,"character":48},"end":{"line":2,"character":49}},"newText":""},{"range":{"start":{"line":2,"character":49},"end":{"line":2,"character":49}},"newText":"\n// for a database connection"}]}]}}]

[Trace - 10:44:38.351 AM] Sending request 'textDocument/codeAction - (9)'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go"},"range":{"start":{"line":0,"character":0},"end":{"line":11,"character":0}},"context":{"diagnostics":[],"only":["source.organizeImports"]}}

[Trace - 10:44:38.354 AM] Received response 'textDocument/codeAction - (9)' in 2ms.
Result: [{"title":"Organize Imports","kind":"source.organizeImports","disabled":{"reason":""},"edit":{"documentChanges":[{"textDocument":{"version":58,"uri":"file:///C:/Users/hakim/work/main.go"},"edits":[{"range":{"start":{"line":0,"character":12},"end":{"line":0,"character":13}},"newText":""},{"range":{"start":{"line":1,"character":0},"end":{"line":1,"character":1}},"newText":""},{"range":{"start":{"line":2,"character":48},"end":{"line":2,"character":49}},"newText":""},{"range":{"start":{"line":2,"character":49},"end":{"line":2,"character":49}},"newText":"\n// for a database connection"}]}]}}]

[Trace - 10:44:38.462 AM] Sending notification 'textDocument/didChange'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go","version":59},"contentChanges":[{"range":{"start":{"line":2,"character":48},"end":{"line":2,"character":48}},"rangeLength":0,"text":"\r\n// for a database connection"}]}

[Trace - 10:44:38.462 AM] Sending request 'textDocument/formatting - (10)'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go"},"options":{"tabSize":4,"insertSpaces":false}}

[Trace - 10:44:38.481 AM] Received response 'textDocument/formatting - (10)' in 18ms.
Result: [{"range":{"start":{"line":0,"character":12},"end":{"line":0,"character":13}},"newText":""},{"range":{"start":{"line":1,"character":0},"end":{"line":1,"character":1}},"newText":""},{"range":{"start":{"line":2,"character":48},"end":{"line":2,"character":49}},"newText":""},{"range":{"start":{"line":3,"character":28},"end":{"line":3,"character":29}},"newText":""},{"range":{"start":{"line":4,"character":28},"end":{"line":4,"character":29}},"newText":""},{"range":{"start":{"line":5,"character":20},"end":{"line":5,"character":21}},"newText":""},{"range":{"start":{"line":6,"character":68},"end":{"line":6,"character":69}},"newText":""},{"range":{"start":{"line":7,"character":8},"end":{"line":7,"character":9}},"newText":""},{"range":{"start":{"line":8,"character":14},"end":{"line":8,"character":15}},"newText":""},{"range":{"start":{"line":9,"character":28},"end":{"line":9,"character":29}},"newText":""},{"range":{"start":{"line":10,"character":30},"end":{"line":10,"character":31}},"newText":""},{"range":{"start":{"line":11,"character":1},"end":{"line":11,"character":2}},"newText":""}]

[Trace - 10:44:38.600 AM] Sending request 'textDocument/foldingRange - (11)'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go"}}

[Trace - 10:44:38.600 AM] Sending notification 'textDocument/didSave'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go","version":59}}

[Trace - 10:44:38.637 AM] Received response 'textDocument/foldingRange - (11)' in 37ms.
Result: [{"startLine":2,"startCharacter":48,"endLine":4,"endCharacter":28,"kind":"comment"},{"startLine":5,"startCharacter":20,"endLine":10,"endCharacter":30},{"startLine":6,"startCharacter":68,"endLine":8,"endCharacter":14,"kind":"comment"}]

[Trace - 10:44:38.896 AM] Sending request 'textDocument/codeAction - (12)'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go"},"range":{"start":{"line":6,"character":46},"end":{"line":6,"character":46}},"context":{"diagnostics":[]}}

[Trace - 10:44:38.896 AM] Sending request 'textDocument/codeLens - (13)'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go"}}

[Trace - 10:44:38.900 AM] Sending request 'textDocument/codeLens - (14)'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go"}}

[Trace - 10:44:38.900 AM] Sending request 'textDocument/documentSymbol - (15)'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go"}}

[Trace - 10:44:38.938 AM] Received response 'textDocument/codeAction - (12)' in 42ms.
Result: [{"title":"Organize Imports","kind":"source.organizeImports","disabled":{"reason":""},"edit":{"documentChanges":[{"textDocument":{"version":59,"uri":"file:///C:/Users/hakim/work/main.go"},"edits":[{"range":{"start":{"line":0,"character":12},"end":{"line":0,"character":13}},"newText":""},{"range":{"start":{"line":1,"character":0},"end":{"line":1,"character":1}},"newText":""},{"range":{"start":{"line":2,"character":48},"end":{"line":2,"character":49}},"newText":""},{"range":{"start":{"line":2,"character":49},"end":{"line":2,"character":49}},"newText":"\n// for a database connection\n// for a database connection"}]}]}}]

[Trace - 10:44:38.938 AM] Received response 'textDocument/codeLens - (13)' in 42ms.
Result: null

[Trace - 10:44:38.938 AM] Received response 'textDocument/codeLens - (14)' in 38ms.
Result: null

[Trace - 10:44:38.938 AM] Received response 'textDocument/documentSymbol - (15)' in 38ms.
Result: [{"name":"Config","detail":"struct{...}","kind":23,"range":{"start":{"line":5,"character":5},"end":{"line":11,"character":1}},"selectionRange":{"start":{"line":5,"character":5},"end":{"line":5,"character":11}},"children":[{"name":"Type","detail":"string","kind":8,"range":{"start":{"line":9,"character":1},"end":{"line":9,"character":28}},"selectionRange":{"start":{"line":9,"character":1},"end":{"line":9,"character":5}}},{"name":"Config","detail":"string","kind":8,"range":{"start":{"line":10,"character":1},"end":{"line":10,"character":30}},"selectionRange":{"start":{"line":10,"character":1},"end":{"line":10,"character":7}}}]}]

[Trace - 10:44:39.193 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///c%3A/Users/hakim/work/main.go","type":2}]}

[Trace - 10:44:39.387 AM] Sending request 'textDocument/documentLink - (16)'.
Params: {"textDocument":{"uri":"file:///c%3A/Users/hakim/work/main.go"}}

[Trace - 10:44:39.389 AM] Received response 'textDocument/documentLink - (16)' in 2ms.
Result: null

</details>

@gopherbot
Copy link

Change https://golang.org/cl/275012 mentions this issue: internal/lsp: fix handling of //-style comments in CRLF files

vscode-go: gopls by default automation moved this from Critical to Done Dec 4, 2020
@gopherbot
Copy link

Change https://golang.org/cl/275437 mentions this issue: [gopls-release-branch.0.5] internal/lsp: fix handling of //-style comments in CRLF files

@stamblerre stamblerre modified the milestones: gopls/v0.6.0, gopls/v0.5.5 Dec 4, 2020
gopherbot pushed a commit to golang/tools that referenced this issue Dec 4, 2020
…ments in CRLF files

As part of the earlier changes, I didn't realize that multiple //-style
comments would be grouped as one *ast.Comment, even though they are
multiple comment tokens. Handle the possibility of multiple consecutive
comment tokens.

Fixes golang/go#42923

Change-Id: I6bc6cbdfb28a8e60c699288528566e406f27514c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275012
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
(cherry picked from commit 73cf035)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275437
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Dec 6, 2020
0.5.5

This is a patch release to fix two bugs in gopls/v0.5.4.

Fixes

Excessive reloading of packages outside of GOPATH or a module

File corruption with CRLF line endings and //-style comments

golang/go#42646 was supposed to have been fixed in gopls/v0.5.4,
but it was not. golang/go#42923 was reported and fixed.

0.5.4

Features

Opening a project that contains a module in a subdirectory

Previously, gopls required that you open your editor exactly at or
below the module root (the directory containing the go.mod). Now,
you can open a directory that contains exactly one module in a
subdirectory, and gopls will work as expected. For details on
multi-module workspaces, see below.

Removal of the granular go.mod upgrade codelenses

Previously, we offered a code lens to suggest upgrades for each
require in a go.mod file. In anticipation of changes that limit
the amount that gopls accesses the network, we have decided to
remove and reevaluate this feature. Users had mentioned that the
code lenses cluttered their go.mod files, especially if they didn't
actually want to upgrade. golang/go#38339 tracks the work to revamp
this feature. An "Upgrade all dependencies" code lens should still
appear at the top of your go.mod file.

Improved error message reports

Previously, critical error messages were reported as message pop-up
that would re-trigger as you type. Many users would find this
annoying. We have changed the approach to show error messages as
progress reports, which should be less intrusive and appear more
like status bars.

Improved memory usage for workspaces with multiple folders

We are now using a coarser cache key for package type information.
If you use the gopls daemon, this may reduce your total memory
usage.

Experimental

Multi-module workspace support

The proposal described in golang/go#32394 is still in development
and off by default. See our progress by tracking the multi-module
workspace milestone and project.

Enable multi-module workspace support by adding the following to
your settings:

"gopls": { "experimentalWorkspaceModule": true, }

With this setting, you will be able to open a directory that contains
multiple modules or a directory that contains nested modules.

Give this a try if you're interested in this new feature, but please
note that it is still very experimental. Please file issues if you
encounter bugs.

Fixes

File corruption with CRLF line endings and /**/-style comments

Previously, when you organized the imports in a file with CRLF line
endings and multi-line comments, the formatter might output incorrect
content for the file, rendering it invalid Go code. This issue has
popped up a number of times, but we believe it has finally been
fixed for good. If you are using Windows with CRLF line ending,
please report any regressions. For full details, see golang/go#42646.
marwan-at-work pushed a commit to marwan-at-work/tools that referenced this issue Dec 23, 2020
As part of the earlier changes, I didn't realize that multiple //-style
comments would be grouped as one *ast.Comment, even though they are
multiple comment tokens. Handle the possibility of multiple consecutive
comment tokens.

Fixes golang/go#42923

Change-Id: I6bc6cbdfb28a8e60c699288528566e406f27514c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/275012
Trust: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
@golang golang locked and limited conversation to collaborators Dec 4, 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
No open projects
Development

No branches or pull requests

5 participants