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

TabNine results yield duplicate letters #45

Closed
jaydorsey opened this Issue Jan 9, 2019 · 14 comments

Comments

Projects
None yet
3 participants
@jaydorsey
Copy link

jaydorsey commented Jan 9, 2019

I'm using TabNine latest, nvim latest, with the deoplete plugin. macOS latest as well. I have semantic completion enabled with solargraph (also latest) as the backend (stdio). My TabNine.toml, .solargraph.yml, and .vimrc files are located here: https://github.com/jaydorsey/dotfiles

I see an issue where the TabNine results show an extra/duplicate letter as in the screenshot below:

image

If I press enter/return it enters the text as present (with the extra character).

Stopping & restarting nvim makes the problem go away, but not for very long.

I don't remember it doing this when I first enabled semantic completion, but I might be mistaken. It seems to have manifested over the last update or two. I've seen it happen with one other user but they have nearly the same setup I have.

Things I've tried that didn't work:

  • Changing the num_server_instances (1 - 4) in TabNine.toml
  • Changing the synchronous_timeout_ms (100-500) in TabNine.toml
  • Updating/clearing/downloading the solargraph-cores
  • Deleting my TabNine.toml file (in hopes that semantic completion would be disabled)
  • Trying a nearly empty vimrc file (also ran PlugClean & restarted nvim after emptying) (below)
  • Trying a nearly empty vimrc, and an empty TabNine.toml file

My mostly empty vimrc file:

set nocompatible  " We don't want vi compatibility.
set termguicolors " Enable true color support
set t_Co=256

let g:python3_host_prog = '/usr/local/bin/python3'
let g:python_host_prog = '/usr/local/bin/python'

call plug#begin()

Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'tbodt/deoplete-tabnine', { 'do': './install.sh' }
let g:deoplete#enable_at_startup = 1
let g:deoplete#ignore_sources = get(g:,'deoplete#ignore_sources',{})
" Disable tags file as a source
let g:deoplete#ignore_sources.ruby = ['tag']

" Use <tab> key to step into the selections
inoremap <expr><tab>  pumvisible() ? "\<c-n>" : "\<tab>"
call plug#end()

This does appear to affect things like trying to type TabNine::restart, even when I don't select rrestart as an autocompletion (I can't call restart by typing)

Other things:

  • I can open up a new nvim instance, aside from one that's been impacted by this, and everything works fine
  • Restarting nvim completely makes the issue go away for a short period of time (minutes)
  • I would try disabling semantic completion, but I don't see a TabNine::disable_sem command?
  • It never does this duplication with any more than the first 2 letters from what I can tell

My next step is to try to revert back to an older version of TabNine to see if I could isolate it vs solargraph but I wanted to see if anyone else was having similiar issues or could recommend a setting I haven't looked at.

@Shougo

This comment has been minimized.

Copy link
Contributor

Shougo commented Jan 9, 2019

I have get the same problem sometimes.
I don't know the reason.

@jaydorsey

This comment has been minimized.

Copy link

jaydorsey commented Jan 9, 2019

One other thing I noticed that may be relevant:

  • When I type one character, everything is OK
  • When I type the 2nd character, I get the double-up (always, once it happens the first time)

This happens almost always within 2-3 minutes of starting vim, with TabNine enabled. This makes it impossible to use because I spend more time moving around deleting text than the time it saves me with autocomplete

tabnine

This screenshot is with all my plugins, but the behavior was the same with the lightweight vimrc file I posted earlier.

Thanks for the info @Shougo. Knowing I'm not the only one should (hopefully) help me narrow down the root cause. I may try the tabnine.vim plugin and see if it occurs there too.

@jaydorsey

This comment has been minimized.

Copy link

jaydorsey commented Jan 9, 2019

@Shougo, I noticed this error immediately before the duplication occurred most recently.

[deoplete] Traceback (most recent call last):
  File "/Users/jay/.config/nvim/plugged/deoplete.nvim/rplugin/python3/deoplete/child.py", line 179, in _gather_results
    result = self._get_result(context, source)
  File "/Users/jay/.config/nvim/plugged/deoplete.nvim/rplugin/python3/deoplete/child.py", line 195, in _get_result
    charpos = source.get_complete_position(ctx)
  File "/Users/jay/.config/nvim/plugged/deoplete-tabnine/rplugin/python3/deoplete/sources/tabnine.py", line 62, in get_complete_position
    self._response = self._get_response(context)
  File "/Users/jay/.config/nvim/plugged/deoplete-tabnine/rplugin/python3/deoplete/sources/tabnine.py", line 109, in _get_response
    max_num_results=10,
  File "/Users/jay/.config/nvim/plugged/deoplete-tabnine/rplugin/python3/deoplete/sources/tabnine.py", line 123, in _request
    return json.loads(proc.stdout.readline().decode('utf8'))
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Error from tabnine: JSONDecodeError('Expecting value: line 1 column 1 (char 0)').  Use :messages / see above for error details.

I'm not sure exactly what I did right before that; I was just writing code.

Edit: I get an error identical to the above every time, then I start getting the duplication in results. Would this be better moved over to deoplete repo as an issue there?

@Shougo

This comment has been minimized.

Copy link
Contributor

Shougo commented Jan 10, 2019

Yes. I have got the same result.
TabNine internal state seems broken.

But it is not every time for me.

Would this be better moved over to deoplete repo as an issue there?

No. It is not deoplete or deoplete-tabnine's error.
deoplete-tabnine just returns output.

Please enable debug mode in deoplete-tabnine and upload the log file when the error is occured.

call deoplete#enable_logging('DEBUG', 'deoplete.log')
call deoplete#custom#source('tabnine', 'is_debug_enabled', 1)
@jaydorsey

This comment has been minimized.

Copy link

jaydorsey commented Jan 10, 2019

I captured a log here: https://gist.github.com/jaydorsey/ad79704a05d9b3fe29b82bbd874e08be

I replaced my actual code with <code> blocks in the log

I'm also able to reproduce this issue reliably now, in at least one scenario. I tried to capture the key commands in the gif below:

screencast 2019-01-10 10-40-49

Basically:

  • Move to top of a file in existing project (this probably doesn't matter)
  • INSERT mode
  • Type a character, wait for autocomplete
  • Press SPACE
  • Press BACKSPACE
  • Press another character

I sometimes have to backspace/type new character a couple times to trigger it.

Possibly of note:

  • I tried to trigger the error with a completely empty file and was NOT able to
  • I tried removing all instances of the characters I used to trigger the autocomplete (pu) from my code, but that still triggered the error
@jaydorsey

This comment has been minimized.

Copy link

jaydorsey commented Jan 10, 2019

Maybe unrelated, but TabNine::Version reports 1.10.0, while my tabnine_config.json file is below:

{"version":"1.0.9","hide_promotional_message":false,"beta_enabled":"No","ignore_all_lsp":false,"semantic_status":{"toml":"Enabled","unknown":"Enabled","ruby":"Enabled"},"disable_auto_update":false}
@jaydorsey

This comment has been minimized.

Copy link

jaydorsey commented Jan 10, 2019

More info on the behavior. I don't know if this would help identify the root cause or not but:

After the issue triggers, when I type a single letter, it reads the previous match (my cursor is after the p below, but it's suggesting stuff based on the With)

image

Typing a second character shows me the doubling:

image

Deleting a character skips the doubling again (replaced p with f but only to show more relevant choices:

image

I've noticed sometimes though, with some words, it's fine. Until i backspace and re-type and then it's all messed up again.

@zxqfl

This comment has been minimized.

Copy link
Owner

zxqfl commented Jan 10, 2019

Here's what I think is happening: TabNine is printing an extra line in its output, causing the readline call at L123 to read that extra line instead of the correct reponse. (This causes the JSONDecodeError.) After that point, each readline call gets TabNine's response to the previous query, leading to the letter doubling effect.

I think TabNine is printing something to stderr. In the most recent version I added some code which logs errors to stderr. This would also explain why I haven't experienced the issue with Sublime, because tabnine-sublime redirects stderr to devnull (L92) whilie deoplete-tabnine redirects it to stdout (L139).

In the next version I will change TabNine to avoid printing to stderr. In the meantime, you could try changing your deoplete-tabnine to redirect stderr to devnull and see if that fixes the issue.

@jaydorsey

This comment has been minimized.

Copy link

jaydorsey commented Jan 10, 2019

Thanks @zxqfl, I just deleted L139 locally to test it (to let the default go to wherever it should go). That seems to have resolved the issue. I'll keep an eye on it, and try a redirect to /dev/null if I see it pop up again. 🤞

@Shougo

This comment has been minimized.

Copy link
Contributor

Shougo commented Jan 11, 2019

Thank you!
I will fix deoplete-tabnine later.
Please wait.

@Shougo

This comment has been minimized.

Copy link
Contributor

Shougo commented Jan 11, 2019

@zxqfl I think tabnine should include error lines in responce instead of stderr.

@Shougo

This comment has been minimized.

Copy link
Contributor

Shougo commented Jan 14, 2019

I have fixed it in tbodt/deoplete-tabnine#17.

@Shougo

This comment has been minimized.

Copy link
Contributor

Shougo commented Jan 14, 2019

The PR is merged. So the problem is gone in deoplete-tabnine.

@jaydorsey

This comment has been minimized.

Copy link

jaydorsey commented Jan 17, 2019

Confirmed, the tabnine + deoplete tabnine changes that came out in recent days have fixed this issue completely. Also, the completion is improved and it's working better than ever. Thanks!

@jaydorsey jaydorsey closed this Jan 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment