deoplete shows snippets for wrong filetype due to python race #360

Closed
joshuarubin opened this Issue Dec 1, 2016 · 5 comments

Projects

None yet

2 participants

@joshuarubin
  1. open a file with snippets
  2. open a new file, with a different filetype, that also has snippets

When creating the new buffer, deoplete emits a BufNew event using the existing buffer's filetype. Immediately after that, deoplete emits a BufRead event using the new buffer's filetype.

The first event BufNew causes neosnippet's on_event handler to trigger for the first buffer's filetype. This handler calls neosnippet#helpers#get_completion_snippets(), but the snippets that are loaded are actually for the new buffer's filetype. Yet, those snippets are then cached for the first buffer's filetype.

As a result, the snippets for the first file are overwritten by the snippets for the second file.

I've fixed this temporarily in my config by disabling the cache in rplugin/python3/deoplete/sources/neosnippet.py, but am not sure if that's the best way to handle things.

A better fix would be for neosnippet#helpers#get_completion_snippets() to require the filetype as a parameter. This would eliminate the race as the function would not need to derive the filetype from the current buffer (which is the source of the race).

@Shougo Shougo added a commit that closed this issue Dec 1, 2016
@Shougo Fix #360 neosnippet source 3929abc
@Shougo Shougo closed this in 3929abc Dec 1, 2016
@Shougo
Owner
Shougo commented Dec 1, 2016

Fixed.

@joshuarubin

The change you committed does not resolve the issue I've described.

@Shougo Shougo reopened this Dec 4, 2016
@Shougo
Owner
Shougo commented Dec 4, 2016 edited

I cannot reproduce the problem!
Your reproduce way is very fuzzy.
Please upload minimal init.vim and reproduce ways from neovim starting.

A better fix would be for neosnippet#helpers#get_completion_snippets() to require the filetype as a parameter. This would eliminate the race as the function would not need to derive the filetype from the current buffer (which is the source of the race).

I don't know why the change is needed.

@Shougo
Owner
Shougo commented Dec 4, 2016

I have removed BufNew event in deoplete.

@Shougo Shougo closed this Dec 4, 2016
@joshuarubin

That worked. Thank you.

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