-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
Comments
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. |
@tomqwpl You can run |
Running that in a terminal window within VSCode gives:
What I wasn't sure about was whether this was what was being used by VSCode. |
@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 |
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:
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. |
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)'. [Trace - 10:44:19.863 AM] Received response 'initialize - (0)' in 0ms. [Trace - 10:44:19.880 AM] Sending notification 'initialized'. [Trace - 10:44:19.880 AM] Sending notification 'textDocument/didOpen'. [Trace - 10:44:19.880 AM] Sending request 'textDocument/documentSymbol - (1)'. [Trace - 10:44:19.880 AM] Sending request 'textDocument/codeAction - (2)'. [Trace - 10:44:19.880 AM] Sending request 'textDocument/documentLink - (3)'. [Trace - 10:44:19.896 AM] Received request 'window/workDoneProgress/create - (1)'. [Trace - 10:44:19.896 AM] Sending response 'window/workDoneProgress/create - (1)' in 0ms. [Trace - 10:44:19.904 AM] Received notification '$/progress'. [Trace - 10:44:19.904 AM] Received request 'workspace/configuration - (2)'. [Trace - 10:44:19.904 AM] Sending response 'workspace/configuration - (2)' in 0ms. [Trace - 10:44:20.257 AM] Sending request 'textDocument/foldingRange - (4)'. [Trace - 10:44:20.258 AM] Sending request 'textDocument/codeLens - (5)'. [Trace - 10:44:20.259 AM] Sending request 'textDocument/codeLens - (6)'. [Trace - 10:44:20.538 AM] Received request 'client/registerCapability - (3)'. [Trace - 10:44:20.540 AM] Received notification 'window/logMessage'. [Info - 10:44:20 AM] 2020/12/02 10:44:20 go env for C:\Users\hakim\work [Trace - 10:44:20.756 AM] Sending response 'client/registerCapability - (3)' in 217ms. [Trace - 10:44:20.758 AM] Received request 'client/registerCapability - (4)'. [Trace - 10:44:20.868 AM] Sending response 'client/registerCapability - (4)' in 110ms. [Trace - 10:44:21.125 AM] Received notification 'window/logMessage'. [Info - 10:44:21 AM] 2020/12/02 10:44:21 go/packages.Load [Trace - 10:44:21.128 AM] Received notification '$/progress'. [Trace - 10:44:21.131 AM] Received response 'textDocument/documentSymbol - (1)' in 1251ms. [Trace - 10:44:21.252 AM] Received response 'textDocument/codeAction - (2)' in 1372ms. [Trace - 10:44:21.294 AM] Received response 'textDocument/documentLink - (3)' in 1414ms. [Trace - 10:44:21.298 AM] Received response 'textDocument/foldingRange - (4)' in 1040ms. [Trace - 10:44:21.317 AM] Received response 'textDocument/codeLens - (5)' in 1058ms. [Trace - 10:44:21.318 AM] Received response 'textDocument/codeLens - (6)' in 1059ms. [Trace - 10:44:23.368 AM] Sending request 'textDocument/documentHighlight - (7)'. [Trace - 10:44:23.371 AM] Received response 'textDocument/documentHighlight - (7)' in 2ms. [Trace - 10:44:23.589 AM] Sending request 'textDocument/codeAction - (8)'. [Trace - 10:44:23.594 AM] Received response 'textDocument/codeAction - (8)' in 5ms. [Trace - 10:44:38.351 AM] Sending request 'textDocument/codeAction - (9)'. [Trace - 10:44:38.354 AM] Received response 'textDocument/codeAction - (9)' in 2ms. [Trace - 10:44:38.462 AM] Sending notification 'textDocument/didChange'. [Trace - 10:44:38.462 AM] Sending request 'textDocument/formatting - (10)'. [Trace - 10:44:38.481 AM] Received response 'textDocument/formatting - (10)' in 18ms. [Trace - 10:44:38.600 AM] Sending request 'textDocument/foldingRange - (11)'. [Trace - 10:44:38.600 AM] Sending notification 'textDocument/didSave'. [Trace - 10:44:38.637 AM] Received response 'textDocument/foldingRange - (11)' in 37ms. [Trace - 10:44:38.896 AM] Sending request 'textDocument/codeAction - (12)'. [Trace - 10:44:38.896 AM] Sending request 'textDocument/codeLens - (13)'. [Trace - 10:44:38.900 AM] Sending request 'textDocument/codeLens - (14)'. [Trace - 10:44:38.900 AM] Sending request 'textDocument/documentSymbol - (15)'. [Trace - 10:44:38.938 AM] Received response 'textDocument/codeAction - (12)' in 42ms. [Trace - 10:44:38.938 AM] Received response 'textDocument/codeLens - (13)' in 42ms. [Trace - 10:44:38.938 AM] Received response 'textDocument/codeLens - (14)' in 38ms. [Trace - 10:44:38.938 AM] Received response 'textDocument/documentSymbol - (15)' in 38ms. [Trace - 10:44:39.193 AM] Sending notification 'workspace/didChangeWatchedFiles'. [Trace - 10:44:39.387 AM] Sending request 'textDocument/documentLink - (16)'. [Trace - 10:44:39.389 AM] Received response 'textDocument/documentLink - (16)' in 2ms.
|
Change https://golang.org/cl/275012 mentions this issue: |
Change https://golang.org/cl/275437 mentions this issue: |
…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
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.
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>
What version of Go are you using (
go version
)?Does 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?
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.
What did you expect to see?
The file to be saved correctly.
What did you see instead?
The comment section being duplicated.
The text was updated successfully, but these errors were encountered: