The unified diff output gopls format includes a \ No newline at end of file line in the middle of the file. Is that valid?
xtools$ git log | head -n 1
commit 7a03febeeead7497d3821eb99461ecfeae51c0ba
xtools$ cat a/a.go
package a
type S struct {
s fmt.Stringer
}
xtools$ go run ./gopls format -d ./a/a.go
--- /Users/adonovan/w/xtools/a/a.go.orig
+++ /Users/adonovan/w/xtools/a/a.go
@@ -1,5 +1,6 @@
package a
type S struct {
+
\ No newline at end of file
s fmt.Stringer
}
xtools$ go run ./gopls format -w ./a/a.go
xtools$ cat ./a/a.go
package a
type S struct {
s fmt.Stringer
}
The text was updated successfully, but these errors were encountered:
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
May 24, 2023
Yes, the code wrongly concludes that an insertion at the beginning of a
line replaces the whole line. There's already a TODO in the code, so some
clear thought is required.
Previously, the expandEdit operation would expand to
the end of the line unconditionally, but this caused it
to gulp an extra line if it was already line-aligned.
This change causes it to do the expansion only if
the end is not line-aligned, or the replacement text
doesn't end with a newline.
Now, removing the fast path no longer causes tests to fail.
This also allows us to remove the logic added in CL 489695
to work around issue golang/go#59232.
Fixesgolang/go#60379Fixesgolang/go#59232
Change-Id: Ia40e4e3bb714d75acb95103a38e8c49a8ef456de
Reviewed-on: https://go-review.googlesource.com/c/tools/+/499377
Run-TryBot: Alan Donovan <adonovan@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
The unified diff output
gopls format
includes a\ No newline at end of file
line in the middle of the file. Is that valid?The text was updated successfully, but these errors were encountered: