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: bug in new diff (unified formatter) #57290

Closed
adonovan opened this issue Dec 13, 2022 · 2 comments
Closed

x/tools/gopls: bug in new diff (unified formatter) #57290

adonovan opened this issue Dec 13, 2022 · 2 comments
Assignees
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

@adonovan
Copy link
Member

adonovan commented Dec 13, 2022

diff.Unified produces a unified diff that patch(1) cannot parse:
(The good diff came from the tests of "gopls format -d" in gopls/internal/lsp/cmd/test/format.go, the bad from the same test after switching to the new diff implementation.)

xtools$ cat good 
--- noparse_format/parse_format.go.orig
+++ noparse_format/parse_format.go
@@ -1,5 +1,5 @@
 package noparse_format //@format("package")
 
 func _() {
-f()
-}
\ No newline at end of file
+	f()
+}
xtools$ cat bad 
--- noparse_format/parse_format.go.orig
+++ noparse_format/parse_format.go
@@ -1,5 +1,6 @@
 package noparse_format //@format("package")
 
 func _() {
+	
\ No newline at end of file
 f()
-}
\ No newline at end of file
+}
xtools$ filename=gopls/internal/lsp/testdata/noparse_format/parse_format.go.in
xtools$ git co HEAD $filename
Updated 0 paths from 066130db08
xtools$ patch -u -p0 < good gopls/internal/lsp/testdata/noparse_format/parse_format.go.in
patching file gopls/internal/lsp/testdata/noparse_format/parse_format.go.in
xtools$ git co HEAD $filename
Updated 1 path from 066130db08
xtools$ patch -u -p0 < bad gopls/internal/lsp/testdata/noparse_format/parse_format.go.in
patching file gopls/internal/lsp/testdata/noparse_format/parse_format.go.in
patch: **** malformed patch at line 8: \ No newline at end of file

@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 13, 2022
@gopherbot gopherbot added this to the Unreleased milestone Dec 13, 2022
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.12.0 Dec 14, 2022
@gopherbot
Copy link

Change https://go.dev/cl/457256 mentions this issue: gopls/internal/hooks: use new diff algorithm unconditionally

@findleyr
Copy link
Contributor

Per @pjweinb, this should be fixed.

@golang golang locked and limited conversation to collaborators Jan 31, 2024
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