Skip to content

x/tools/gopls: unimported completions produces invalid edits with windows line endings when CRLF is used #46791

Closed
@DmitriyVTitov

Description

@DmitriyVTitov

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.16.3 windows/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • golang.org/x/tools/gopls v0.6.11
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.56.0 x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.24.2
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

gopath: C:\Users\dtsp\YandexDisk\go
GOROOT: c:\go
PATH: C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Git\cmd;C:\Program Files\nodejs;C:\Program Files\Graphviz 2.44.1\bin;C:\Go\bin;C:\Users\dtsp\AppData\Local\Microsoft\WindowsApps;C:\Users\dtsp\AppData\Roaming\npm;C:\Users\dtsp\go\bin;C:\Users\dtsp\YandexDisk\go\bin;C:\Users\dtsp\AppData\Local\GitHubDesktop\bin;c:\flutter\bin;C:\msys64\mingw64\bin;C:\Users\dtsp\AppData\Local\Microsoft\WindowsApps;C:\Users\dtsp\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\dtsp\go\bin

gopkgs: C:\Users\dtsp\YandexDisk\go\bin\gopkgs.exe installed
go-outline: C:\Users\dtsp\YandexDisk\go\bin\go-outline.exe installed
gotests: C:\Users\dtsp\YandexDisk\go\bin\gotests.exe installed
gomodifytags: C:\Users\dtsp\YandexDisk\go\bin\gomodifytags.exe installed
impl: C:\Users\dtsp\YandexDisk\go\bin\impl.exe installed
goplay: C:\Users\dtsp\YandexDisk\go\bin\goplay.exe installed
dlv: C:\Users\dtsp\YandexDisk\go\bin\dlv.exe installed
dlv-dap: dlv-dap not installed
staticcheck: C:\Users\dtsp\YandexDisk\go\bin\staticcheck.exe installed
gopls: C:\Users\dtsp\YandexDisk\go\bin\gopls.exe installed

Describe the bug

When second imported package is called in source code it is autoimported in the same line as first one.

Steps to reproduce the behavior:

package ex

import "fmt"

func ex() {
	fmt.Println("ABC")
}

Then add for ex. math.Sqrt(2)

package ex

import (
	"fmt"	"math"
)


func ex() {
	fmt.Println("ABC")
	math.Sqrt(2)
}

Screenshots or recordings

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions