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: formatting with missing final line break clears last line #33717

Closed
carlpett opened this issue Aug 19, 2019 · 12 comments
Closed
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@carlpett
Copy link

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

$ go version
go version go1.12.6 linux/amd64

Does this issue reproduce with the latest release?

Yes, of gopls, at least.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/cape/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/cape/dev"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/golang"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/PATH-TO-MY-MODULE/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build692302619=/tmp/go-build -gno-record-gcc-switches"

Also, running in Sublime with LSP package, if relevant.

What did you do?

Write code. Do not place final empty newline. Format.

package main

import (
	"fmt"
)

func main() {
	fmt.Println("Hello, world")
} // No newline!

What did you expect to see?

Newline added to the end of the file

package main

import (
	"fmt"
)

func main() {
	fmt.Println("Hello, world")
} // Added newline!

What did you see instead?

Last line cleared.

package main

import (
	"fmt"
)

func main() {
	fmt.Println("Hello, world")
@gopherbot gopherbot added this to the Unreleased milestone Aug 19, 2019
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Aug 19, 2019
@gopherbot
Copy link

Thank you for filing a gopls issue! Please take a look at the Troubleshooting section of the gopls Wiki page, and make sure that you have provided all of the relevant information here.

@ianthehat
Copy link

This might be an issue with sublime, we have a test specifically for this case that passes, and I cannot reproduce in either VSCode or vim.
Can you try using gopls from the command line with gopls format -w <filename> and see if works normally, if so it is almost definitely a problem with the way sublime applies past end of file edits.

@carlpett
Copy link
Author

Yep, seems to be the case, commandline works. Is this something which I should report to Sublime or the LSP extension?

@ianthehat
Copy link

Honestly I am not sure, I do not use/run/understand sublime. My guess would be the lsp extension as formatting and the application of edits should be a fundamental feature of lsp integration.
I am going to close this issue, please feel free to comment again if you need it re-opened or if sublime reports there is something we are doing wrong.

@haferburg
Copy link

@ianthehat Hi there! Please have a look at sublimelsp/LSP#690. We think that the server sends an invalid line number. In this example, the file has lines 0..8, and the server requests are for line 9/column 0.

@stamblerre stamblerre reopened this Aug 24, 2019
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Sep 12, 2019
@stamblerre
Copy link
Contributor

It looks like the upstream issue in the Sublime repository has been closed. @haferburg is this still an issue?

@stamblerre stamblerre added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Nov 7, 2019
@haferburg
Copy link

@stamblerre Yea, I think so sublimelsp/LSP#717

@stamblerre stamblerre assigned ianthehat and stamblerre and unassigned stamblerre Nov 7, 2019
@stamblerre stamblerre changed the title x/tools/cmd/gopls: Formatting with missing final line break clears last line x/tools/cmd/gopls: formatting with missing final line break clears last line Nov 7, 2019
@stamblerre stamblerre modified the milestones: Unreleased, gopls v1.0 Dec 4, 2019
@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@stamblerre stamblerre removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Dec 7, 2019
@stamblerre
Copy link
Contributor

My apologies - the WaitingForInfo label should have been removed. I will try to investigate this soon.

@ianlancetaylor ianlancetaylor reopened this Dec 7, 2019
@pjweinbgo
Copy link
Contributor

Why is this still open? In any case, it shouldn't be blocking 1.0.0

@stamblerre stamblerre added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 28, 2020
@stamblerre
Copy link
Contributor

I left it open because it seemed to still require investigation (#33717 (comment)). I'm trying to mark all issues that still need investigation as gopls/v1.0.0 to make sure that we at least take a look at them (and maybe decide they aren't actually gopls/v1.0.0).

@stamblerre stamblerre changed the title x/tools/cmd/gopls: formatting with missing final line break clears last line x/tools/gopls: formatting with missing final line break clears last line Jan 30, 2020
@stamblerre stamblerre modified the milestones: gopls/v1.0.0, gopls/v0.4.0 Feb 2, 2020
@stamblerre stamblerre modified the milestones: gopls/v0.4.0, gopls/v0.5.0 Apr 2, 2020
@stamblerre
Copy link
Contributor

Looks like the upstream repository handled it (sublimelsp/LSP#717), so I'm going to close this since all other clients have supported it. If it becomes an issue again, we can reassess.

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. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

7 participants