-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Omnicomplete deletes text before cursor when completeopt=longest,menuone and shows erroneous matches #2730
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
Comments
Does adding |
I gave it a try, same result. I verified that it was set correctly using |
The completion candidates are provided by gopls. The only options that vim-go has to control how gopls behaves are documented in vim-go's help (e.g. @stamblerre would you expect the candidates that @shabbyrobe mentioned to be provided by gopls? @shabbyrobe if you can reproduce the prefix deletions you're seeing, I'll see if I can find an explanation. I'll say up front, though, that I use completion daily and haven't noticed the problem you're describing. However, there are some sometimes surprising behaviors by Vim itself. |
Thanks for the detailed response, @bhcleek! I think the details I've provided here alone are sufficient to reproduce the issue - I can see it reliably when I follow the steps on my own machine. I mentioned earlier that I haven't worked out an exact repro for one aspect of it (where it deletes the entire word before the cursor, rather than just part of it), but the part I have reported appears to be reproducible with the details I've provided here. If it'd save you the trouble of risking some time on it, I can try to confirm inside a VM with an absolutely fresh install of Vim, Go, vim-go and gopls just to make extra-double-sure something from my environment is not confounding the result, but I'm 95% confident the recompiled Vim did the trick for excluding my normal |
For Also the help for Is there something I can do with |
With regard to If you can find a way to duplicate deletion you're seeing, it's probably quick to resolve if it's due to a bug in vim-go. The only thing I can think of that could potentially be an issue is if there are multi-byte characters on the line where you're trying to do completion. While that should be handled correctly, I can imagine scenarios where a bug around the multi-byte character handling could cause what you're describing. |
Ah yep, makes sense. I reckon that's not what's going on here, there are no multibyte chars in the repro I posted, and they occur very, very rarely in the code I work with. I grabbed the
|
Those logs are what I would expect. I'll wait for Rebecca to weigh-in regarding whether the candidates are expected (my suspicion is that they are). Let me know if you find a way to replicate the too-aggressive deletion. |
I just had a bit more of a play around and I think I have it! package main
type Stuff struct{}
type ThingoStuff struct{}
func main() {
var v Stuff_ # <--- here at the "cursor", I press <C-X>, <C-O>
} The menu shows gopls logsent: Content-Length: 156 |
Thank you! That's really helpful. I can duplicate what you're seeing. Strangely, it only occurs when Here's what I know based off of experimenting with the repro path you provided:
I'm not 100% sure, but I think this might be a Vim issue that occurs in some cases when |
@muirdm would know best, but I don't believe |
gopls candidates contain text edits to overwrite the prefix with the entire candidate. For example completing "fo" to "food" will give a text edit that inserts "food" over "fo", as opposed to just appending "od" to "fo". |
That's fine for vim-go's purposes; it only means that vim-go returns that information from the completion function. I suspect that @shabbyrobe is encountering has to do with how Vim deals with
|
I pulled my repro process together into a script to try to bisect when this issue appeared in I think that eliminates this as an issue introduced into vim with the I'll try to find some time to do the same for gopls and vim-go versions next. If I can find the earliest version that doesn't reproduce the problem I'll report back. It's also possible that my memory is murky: the Go Modules transition period made a lot of things about my previously-working setup a bit creaky (that have been steadily getting resolved) so for all I remember, it has just always done this since I switched from gocode to gopls. I apologise, this is getting a bit spongy, I'll go and try to get some more hard data. |
Given the differences in what gocode provided vs what gopls provides, it would not surprise me if the behavior your seeing correlates to gopls and gopls, specifically around #2291. However, what vim-go and gopls are providing is well within the documented requirements for Vim's completion. I've looked for an issue in github.com/vim/vim/issues about this, but haven't been able to find anything. |
Ah cool, so you reckon I should look at gathering material to submit a bug to Vim instead? |
Yes. I don't see anything here that makes me think this is anything other than a Vim issue. ref: |
Hey just checking, was a bug raised to Vim for this? |
What did you do? (required: The issue will be closed when not provided)
I created an empty folder, ran
go mod init example.com/yep
, then made surecompleteopt
was tolongest,menuone
, created two variables with a common prefix, started typingfo
, then invoked<C-X>, <C-O>
:What did you expect to happen?
I expect to see the
fo
prefix I typed in-tact and the two completion options based on that prefix (fooo
andfood
) in the popup:What happened instead?
The prefix is partially deleted and incorrect completion options appear (
float32
,float64
). Sometimes the prefix is deleted in its entirety, but I still haven't got a reliable repro for the full deletion scenario yet, which is unfortunate because it happens frequently in practice:Configuration (MUST fill this out):
Unfortunately, I couldn't work out how to get vim to start with a fully separate
vim
andvimrc
while still loading plugins (--clean
ignores them), so I just built from source after usingruplacer
to replace every single instance of~/.vim
in the source with/tmp/vimconf/vim
(to force it to use/tmp/vimconf/vimrc
and/tmp/vimconf/vim
and ignore my home dir):I then set up the following hierarchy in
/tmp/vimconf
, wherevim-go
is a clone of this repo atmaster
, andvimrc
contains the lines pasted below (very minimal):I could then invoke vim from within my Go module's root like so:
/tmp/viminst/bin/vim -u /tmp/vimconf/vimrc main.go
. Even after my dirty hack on the source, I still needed the-u
argument, but at least that got me the clean result I was after in the end.(As an aside, if there's an easier way to do this kind of repro with a clean Vim that doesn't involve the silly things I've done here hacking the source up, I'd be grateful for any pointers.)
vim-go version:
master
, but this has been going on for months.vimrc
you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):vimrc
Vim version (first three lines from
:version
):I tried to set this repro up in 8.2.0268, but the issue has also been present in all versions of 8.2 I have used. May have also been present in 8.1, but I don't believe the problem is in vim, I think it's in vim-go, as my TypeScript, Rust and Python setups all continue to work exactly as expected.
Go version (
go version
):Tried with 1.13 and 1.14rc1
Go environment
go env
Output:gopls version
gopls version
Output:Problem was also present with pinned version.
The text was updated successfully, but these errors were encountered: