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

auto complete package imports #6

Open
MordFustang21 opened this issue Feb 28, 2020 · 3 comments
Open

auto complete package imports #6

MordFustang21 opened this issue Feb 28, 2020 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@MordFustang21
Copy link
Owner

When the editor adds the missing import it injects the completion selection incorrectly. Ex.

package main

import "fmt"

func main() {
  fmt.Println("hello world")
  log
}

becomes

package main

import (
	"log"
)
	"fmt"

func main() {
  fmt.Println("hello world")
  log
}
@MordFustang21 MordFustang21 added bug Something isn't working good first issue Good for newcomers labels Feb 28, 2020
@stamblerre
Copy link

This sounds like it could be an issue in the Atom language client library. The imports are added via the additional text edits field of a completion item: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#textDocument_completion.

@MordFustang21
Copy link
Owner Author

I'm 99% sure this is an issue with ide-gopls. I had to add special code when I did this the first time around to apply the additional edits see https://github.com/MordFustang21/ide-gopls/blob/master/lib/main.js#L68

marcelkohl added a commit to marcelkohl/ide-gopls that referenced this issue May 18, 2021
Issue MordFustang21#6.

The issue is that gopls sends back the coordinates for the text in the 
actual buffer and does not consider the changes made along the replaces. 
So, as soon as the first replace in the text happens all other 
coordinates are automatically wrong.

Replaced text suggestions from bottom to top (reverse for-each), so it 
will prevent text to be moved from it's original place.
@marcelkohl
Copy link
Contributor

fixed on PR #16

MordFustang21 pushed a commit that referenced this issue Jun 4, 2021
Issue #6.

The issue is that gopls sends back the coordinates for the text in the 
actual buffer and does not consider the changes made along the replaces. 
So, as soon as the first replace in the text happens all other 
coordinates are automatically wrong.

Replaced text suggestions from bottom to top (reverse for-each), so it 
will prevent text to be moved from it's original place.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants