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: find definition should return filename part as it is under Windows #47481

Closed
wsw0108 opened this issue Jul 31, 2021 · 6 comments
Closed
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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@wsw0108
Copy link

wsw0108 commented Jul 31, 2021

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

$ go version
go version go1.16 windows/amd64

Does this issue reproduce with the latest release?

Yes.

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

Windows 10, x64

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\wsw\AppData\Local\go-build
set GOENV=C:\Users\wsw\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows

What did you do?

Using gopls with eglot((setq eglot-extend-to-xref t)).

xref-find-definitions under math.Abs(...).

What did you expect to see?

No new gopls server starts for the 'xrefed' go standard library file.

What did you see instead?

A new gopls server starts for the 'xrefed' go standard library file.

EGLOT event buffer:

[client-request] (id:4) Sat Jul 31 11:14:35 2021:
(:jsonrpc "2.0" :id 4 :method "textDocument/definition" :params
          (:textDocument
           (:uri "file:///f%3A/GitHub/ombb/point.go")
           :position
           (:line 50 :character 14)))
[server-reply] (id:4) Sat Jul 31 11:14:35 2021:
(:jsonrpc "2.0" :result
          [(:uri "file:///C:/go/src/math/abs.go" :range
                 (:start
                  (:line 11 :character 5)
                  :end
                  (:line 11 :character 8)))]
          :id 4)

buffer-file-name for opened buffer c:/Go/src/math/abs.go.

https://github.com/joaotavora/eglot/blob/194b178ef41ccd3d937983f3829d44a546bb24d6/eglot.el#L1598-L1601

@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Jul 31, 2021
@wsw0108
Copy link
Author

wsw0108 commented Jul 31, 2021

file:///C:/go and c:/Go, it is crazy...

Maybe this should be resolved in eglot?

(directory-file-name "C:/Go/src/math/abs.go") ;; c:/Go/src/math/abs.go

cc @joaotavora

@seankhliao seankhliao changed the title gopls: find definition should return filename part as it is under Windows x/tools/gopls: find definition should return filename part as it is under Windows Jul 31, 2021
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Jul 31, 2021
@gopherbot gopherbot added this to the Unreleased milestone Jul 31, 2021
@findleyr
Copy link
Contributor

Hi, could you please share your full LSP logs for a session that produces this bug (see instructions here)? That will help pinpoint where the incorrect casing is coming from.

Thanks.

@findleyr findleyr added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Jul 31, 2021
@joaotavora
Copy link

joaotavora commented Jul 31, 2021

@wsw0108 mentioning Eglot specific details to the authors of a language server is unlikely to be productive. You should post the requested details, nevertheless. If you want to open an issue in the Eglot tracker, you can, provided you follow the template there. If you don't have those details, you can also start a conversation in Eglot's discussion forum.

@findleyr from what I could gather of this description the problem had nothing to do with gopls

@wsw0108
Copy link
Author

wsw0108 commented Aug 1, 2021

@findleyr log attached.
gopls.txt

Actually, the log file was generated after I modify eglot, otherwise after I call textDocument/definition, the log fill will be overwrited by the new gopls process.

  • go env GOROOT, c:/go
  • reply for textDocument/definition, file:///C:/go/src/math/abs.go
  • (buffer-file-name)(Emacs), c:/Go/src/math/abs.go

@wsw0108
Copy link
Author

wsw0108 commented Aug 1, 2021

reproduce repo https://github.com/wsw0108/CASE-eglot.

eglot-gopls.txt

cd CASE-eglot
emacs -Q -l init.el test.go

@findleyr
Copy link
Contributor

findleyr commented Aug 3, 2021

Thanks for the logs, as they made it apparent that it is indeed gopls that is producing the upper-cased drive name.

Investigating, gopls actually always uses upper-case drive names in its URIs: see #36904. Because windows drive names are not case sensitive, gopls does this to normalize paths returned from different sources.

Unless I'm missing something, it seems like this must be handled client-side, i.e. in emacs.

I'm closing because I don't think there's anything we can reasonably do here, but please re-open if there's more to discuss.

@findleyr findleyr closed this as completed Aug 3, 2021
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.7.2 Aug 6, 2021
@golang golang locked and limited conversation to collaborators Aug 6, 2022
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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants