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: support insertReplaceEdit results in completion items #48769

Closed
jpap opened this issue Sep 27, 2021 · 3 comments
Closed

x/tools/gopls: support insertReplaceEdit results in completion items #48769

jpap opened this issue Sep 27, 2021 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. help wanted 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.

Comments

@jpap
Copy link
Contributor

jpap commented Sep 27, 2021

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

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.17 darwin/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
Build info
----------
golang.org/x/tools/gopls v0.7.2
    golang.org/x/tools/gopls@v0.7.2 h1:kRKKdvA8GOzra8rhSFDClOR7hV/x8v0J0Vm4C/gWq8s=
    github.com/BurntSushi/toml@v0.4.1 h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw=
    github.com/google/go-cmp@v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
    golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
    golang.org/x/sys@v0.0.0-20210809222454-d867a43fc93e h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA=
    golang.org/x/tools@v0.1.6-0.20210908190839-cf92b39a962c h1:C0nyHiBU2m0cR6hDiUORWqQIt3h37wsp1255QBSSXqY=
    golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
    honnef.co/go/tools@v0.2.0 h1:ws8AfbgTX3oIczLPNPCu5166oBg9ST2vNs0rcht+mDE=
    mvdan.cc/gofumpt@v0.1.1 h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA=
    mvdan.cc/xurls/v2@v2.3.0 h1:59Olnbt67UKpxF1EwVBopJvkSUBmgtb468E4GVWIZ1I=
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

    • 1.60.2
      7f6ab5485bbc008386c4386d08766667e155244e
      x64
  • Check your installed extensions to get the version of the VS Code Go extension

    • v0.28.1

Describe the bug

  • When performing an autocomplete, vscode-go replaces the word under the cursor, even though the VSC editor.suggest.insertMode setting is set to "insert".
  • When editor.suggest.insertMode is set to "insert", the word under the cursor should remain in-place, as demonstrated in this video.

Example

Let's say I was editing the following line, where represents the current cursor position:

if ✎filepath.Ext(myPath) == ".txt" {

I want to change the comparison to lowercase, so I type strings. at which time the suggestions dropdown appears. If I select ToLower, then vscode-go will replace it as follows,

if strings.ToLower(✎).Ext(myPath) == ".txt" {

where it has replaced filepath with the suggestion.

But because my VSCode editor.suggest.insertMode setting is set to "insert", I would have expected,

if strings.ToLower(✎)filepath.Ext(myPath) == ".txt" {

where the suggestion has been inserted at the original cursor position.

Bonus points

In the above example, if vscode-go could instead wrap the expression at the cursor, as follows, it would result in even greater productivity:

if strings.ToLower(✎filepath.Ext(myPath)) == ".txt" {
@findleyr
Copy link
Contributor

findleyr commented Oct 4, 2021

CC @stamblerre @muirdm @hyangah

IIUC, this would require gopls implementing support for insertReplaceEdit. Transferring to the gopls issue tracker.

@findleyr findleyr transferred this issue from golang/vscode-go Oct 4, 2021
@findleyr findleyr changed the title Completions don't respect editor.suggest.insertMode x/tools/gopls: support insertReplaceEdit results in completion items Oct 4, 2021
@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 Oct 4, 2021
@gopherbot gopherbot added this to the Unreleased milestone Oct 4, 2021
@findleyr findleyr modified the milestones: Unreleased, gopls/unplanned Oct 4, 2021
@findleyr findleyr added help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Oct 4, 2021
@muirdm
Copy link

muirdm commented Oct 4, 2021

Possible dupe of #40871

@findleyr
Copy link
Contributor

findleyr commented Oct 4, 2021

Thanks @muirdm, I think it makes sense to dedupe to #40871

@findleyr findleyr closed this as completed Oct 4, 2021
@stamblerre stamblerre removed this from the gopls/unplanned milestone Oct 4, 2021
@golang golang locked and limited conversation to collaborators Oct 4, 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. help wanted 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

5 participants