Youcompleteme: YCM doubles input at end of line

Created on 26 Sep 2017  路  16Comments  路  Source: ycm-core/YouCompleteMe

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside
the brackets) _before_ filing your issue:

  • [x] I have read and understood YCM's CONTRIBUTING document.
  • [x] I have read and understood YCM's CODE_OF_CONDUCT document.
  • [x] I have read and understood YCM's README, especially the
    Frequently Asked Questions section.
  • [x] I have searched YCM's issue tracker to find issues similar to the one I'm
    about to report and couldn't find an answer to my problem. (Example Google
    search.
    )
  • [x] If filing a bug report, I have included the output of vim --version.
  • [x] If filing a bug report, I have included the output of :YcmDebugInfo.
  • [x] If filing a bug report, I have attached the contents of the logfiles using
    the :YcmToggleLogs command.
  • [x] If filing a bug report, I have included which OS (including specific OS
    version) I am using.
  • [x] If filing a bug report, I have included a minimal test case that reproduces
    my issue, including what I expected to happen and what actually happened.
  • [x] (n/a) If filing a installation failure report, I have included the entire output
    of install.py (or cmake/make/ninja) including its invocation
  • [x] I understand this is an open-source project staffed by volunteers and
    that any help I receive is a selfless, heartfelt _gift_ of their free time. I
    know I am not entitled to anything and will be polite and courteous.
  • [x] I understand my issue may be closed if it becomes obvious I didn't
    actually perform all of these steps.

Thank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.

Issue Details

What did you do?

Open a new file, in this case tmp.py. :set tw=5, then in insert mode type asdf a asdf.

What did you expect to happen?

I expected to get a file that looks like this:

a
asdf

What actually happened?

I got a file that looks like this:

a
asasdf

What seems to happen is that when vim wraps a line partway through a word that YCM is trying to complete, I end up with the first few characters of the word duplicated. This only happens if the word is in the autocomplete options, thus typing a asdf alone doesn't trigger it, I have to have asdf somewhere else in the file.

Thanks very much in advance for your help (and for a great plugin)!

Diagnostic data

See gist. The three log files not included were empty.

I've tested this with a clean vimrc and only pathogen + YouCompleteMe (latest master) in my .vim. (I believe this was introduced somewhere in b358b5ba...31e5fa6d. I realize that's a pretty giant range so if I have time later I'll try a bisect.) It seems to happen for any non-null filetype. The tw=5 is only to simplify the reproduction; it happens with more reasonable text widths too.

OS version, distribution, etc.

Ubuntu 17.04, here's uname -a: Linux diffeomorphism 4.10.0-35-generic #39-Ubuntu SMP Wed Sep 13 07:46:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Most helpful comment

@benjaminjkraft You need to update your Vim to at least 8.0.0127.

All 16 comments

Thanks for the report. I am not getting exactly the same issue when following your steps using this vimrc:

set nocompatible

set runtimepath+=/path/to/YouCompleteMe

filetype plugin indent on

set textwidth=5

but it's not far off:

textwidth-bug

If I press <TAB> then I get the same result. Anyway, this should be fixed but I am not sure how.

Probably related to issue https://github.com/Valloric/YouCompleteMe/issues/771.

I've played with this and came to the conclusion that there doesn't need to be a valid candidate to trigger this bug.

@benjaminjkraft You need to update your Vim to at least 8.0.0127.

@micbou , I have exactly the behavior you described in your former message (Tab triggers the mess), but my Vim version is

:version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct 12 2018 19:49:42)

It results very annoying to me, since I tend to Tab-complete with considerable frequency.

@Aster89 Sorry, I can't reproduce with Vim 8.1.477.

Just to be sure I'm doing the same thing, I encounter the problem when I run

$ vi -u <(echo -e "set nocompatible\nset runtimepath+=.vim/plugged/YouCompleteMe/\nfiletype plugin indent on\nset textwidth=5") tmp.py

and then hit iasdfSpaceaSpaceasdfTab.

I didn't check this properly. The suggestion is not inserted anymore when Vim automatically wraps the text, which was the issue initially reported by the OP, but the completion menu still appears at the wrong position like in the GIF animation of my comment. Reopening.

So, when vim hardwraps the line and moves the word to the next line, we are keeping the previous start codepoint. What's interesting is that vim doesn't automatically wrap the second asdf until you exit insert mode if you start vim with --noplugins.

PR https://github.com/Valloric/YouCompleteMe/pull/3192 should fix the issue. @Aster89 Could you give it a try?

So, when vim hardwraps the line and moves the word to the next line, we are keeping the previous start codepoint. What's interesting is that vim doesn't automatically wrap the second asdf until you exit insert mode if you start vim with --noplugins.

Strange, I don't experience this.

I'd be glad to check and let you know if it works, but... How can I get your changes from command line?

Go to the YCM folder and run the commands

git fetch origin pull/3192/head:auto-wrap
git checkout auto-wrap

Once you are done, you can go back to the current version of YCM with

git checkout master

It works, as long as the example we've been trying so far is exhaustive.

@micbou , for my own reference and understanding, pull/3192 is the pull request, auto-wrap is the name of the branch you created to work. Where should have I understood that head: was needed and not anything else?

It works, as long as the example we've been trying so far is exhaustive.

You could try the changes for a few days and report back if you encounter any issue.

@micbou , for my own reference and understanding, pull/3192 is the pull request, auto-wrap is the name of the branch you created to work. Where should have I understood that head: was needed and not anything else?

head is actually part of the name of the branch that store the changes of PR #3192: pull/3192/head. When a PR is opened, GitHub creates a hidden branch on the repository named pull/{id}/head where {id} is the PR number. In Git terminology, head refers to the tip of the branch i.e. the latest version so pull/{id}/head can be understood as the latest version of PR #{id}.

Oh, indeed PRs can consist of more commits, right. Ok, I think I got it.

Btw, yes, I'll use it and I won't report as long as I don't encounter issues. (I think I should be notified by e-mail if this is merged in master, right?)

I think I should be notified by e-mail if this is merged in master, right?

Yes, you will be notified if you are watching the repository or if you are subscribed to this issue or the PR.

Was this page helpful?
0 / 5 - 0 ratings