carlitux / deoplete-ternjs

deoplete.nvim source for javascript
MIT License
277 stars 24 forks source link

neovim.api.nvim.NvimError: b'Index out of bounds' #34

Closed dbellavista closed 7 years ago

dbellavista commented 7 years ago

I don't know if the error is for deoplete or deoplete-ternjs

[deoplete] Traceback (most recent call last):                                                                                                                                     
[deoplete] Traceback (most recent call last):                                                                                                                                     
[deoplete]   File "/Users/daniele/.config/nvim/plugged/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 100, in gather_results                        
[deoplete]   File "/Users/daniele/.config/nvim/plugged/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 100, in gather_results                        
[deoplete]     ctx['candidates'] = source.gather_candidates(ctx)                                                                                                                  
[deoplete]     ctx['candidates'] = source.gather_candidates(ctx)                                                                                                                  
[deoplete]   File "/Users/daniele/.config/nvim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 351, in gather_candidates                                
[deoplete]   File "/Users/daniele/.config/nvim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 351, in gather_candidates                                
[deoplete]     result = self.completation(pos) or []                                                                                                                              
[deoplete]     result = self.completation(pos) or []                                                                                                                              
[deoplete]   File "/Users/daniele/.config/nvim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 307, in completation                                     
[deoplete]   File "/Users/daniele/.config/nvim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 307, in completation                                     
[deoplete]     data = self.run_command(command, pos)                                                                                                                              
[deoplete]     data = self.run_command(command, pos)                                                                                                                              
[deoplete]   File "/Users/daniele/.config/nvim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 192, in run_command                                      
[deoplete]   File "/Users/daniele/.config/nvim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 192, in run_command                                      
[deoplete]     f = self.buffer_fragment()                                                                                                                                         
[deoplete]     f = self.buffer_fragment()                                                                                                                                         
[deoplete]   File "/Users/daniele/.config/nvim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 274, in buffer_fragment                                  
[deoplete]   File "/Users/daniele/.config/nvim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 274, in buffer_fragment                                  
[deoplete]     "text": self.buffer_slice(buffer, start, end),                                                                                                                     
[deoplete]     "text": self.buffer_slice(buffer, start, end),                                                                                                                     
[deoplete]   File "/Users/daniele/.config/nvim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 242, in buffer_slice                                     
[deoplete]   File "/Users/daniele/.config/nvim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 242, in buffer_slice                                     
[deoplete]     text += buf[pos] + "\n"                                                                                                                                            
[deoplete]     text += buf[pos] + "\n"                                                                                                                                            
[deoplete]   File "/usr/local/lib/python3.5/site-packages/neovim/api/buffer.py", line 45, in __getitem__                                                                          
[deoplete]   File "/usr/local/lib/python3.5/site-packages/neovim/api/buffer.py", line 45, in __getitem__                                                                          
[deoplete]     return self.request('nvim_buf_get_lines', i, i + 1, True)[0]                                                                                                       
[deoplete]     return self.request('nvim_buf_get_lines', i, i + 1, True)[0]                                                                                                       
[deoplete]   File "/usr/local/lib/python3.5/site-packages/neovim/api/common.py", line 44, in request                                                                              
[deoplete]   File "/usr/local/lib/python3.5/site-packages/neovim/api/common.py", line 44, in request                                                                              
[deoplete]     return self._session.request(name, self, *args, **kwargs)                                                                                                          
[deoplete]     return self._session.request(name, self, *args, **kwargs)                                                                                                          
[deoplete]   File "/usr/local/lib/python3.5/site-packages/neovim/api/nvim.py", line 131, in request                                                                               
[deoplete]   File "/usr/local/lib/python3.5/site-packages/neovim/api/nvim.py", line 131, in request                                                                               
[deoplete]     res = self._session.request(name, *args, **kwargs)                                                                                                                 
[deoplete]     res = self._session.request(name, *args, **kwargs)                                                                                                                 
[deoplete]   File "/usr/local/lib/python3.5/site-packages/neovim/msgpack_rpc/session.py", line 98, in request                                                                     
[deoplete]   File "/usr/local/lib/python3.5/site-packages/neovim/msgpack_rpc/session.py", line 98, in request                                                                     
[deoplete]     raise self.error_wrapper(err)                                                                                                                                      
[deoplete]     raise self.error_wrapper(err)                                                                                                                                      
[deoplete] neovim.api.nvim.NvimError: b'Index out of bounds'                                                                                                                      
[deoplete] neovim.api.nvim.NvimError: b'Index out of bounds'                                                                                                                      
[deoplete] Could not get completions from: ternjs.  Use :messages for error details.                                                                                              
[deoplete] Could not get completions from: ternjs.  Use :messages for error details.                                                                                              
alem0lars-yr commented 7 years ago

I'm having the same error..

Are there any news?

carlitux commented 7 years ago

a way to reproduce it? please provide the steps

joaumg commented 7 years ago

I get the same error, but with a different stacktrace:

[deoplete] Traceback (most recent call last):                                                                                                                                     
[deoplete] Traceback (most recent call last):                                                                                                                                     
[deoplete]   File "/home/developer-01/.vim/plugged/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 110, in gather_results                                               
[deoplete]   File "/home/developer-01/.vim/plugged/deoplete.nvim/rplugin/python3/deoplete/deoplete.py", line 110, in gather_results                                               
[deoplete]     ctx['candidates'] = source.gather_candidates(ctx)                                                                                                                  
[deoplete]     ctx['candidates'] = source.gather_candidates(ctx)                                                                                                                  
[deoplete]   File "/home/developer-01/.vim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 354, in gather_candidates                                    
[deoplete]   File "/home/developer-01/.vim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 354, in gather_candidates                                    
[deoplete]     result = self.completation(pos) or []                                                                                                                              
[deoplete]     result = self.completation(pos) or []                                                                                                                              
[deoplete]   File "/home/developer-01/.vim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 298, in completation                                         
[deoplete]   File "/home/developer-01/.vim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 298, in completation                                         
[deoplete]     data = self.run_command(command, pos)                                                                                                                              
[deoplete]     data = self.run_command(command, pos)                                                                                                                              
[deoplete]   File "/home/developer-01/.vim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 195, in run_command                                          
[deoplete]   File "/home/developer-01/.vim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 195, in run_command                                          
[deoplete]     doc['files'].append(self.full_buffer())                                                                                                                            
[deoplete]     doc['files'].append(self.full_buffer())                                                                                                                            
[deoplete]   File "/home/developer-01/.vim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 231, in full_buffer                                          
[deoplete]   File "/home/developer-01/.vim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 231, in full_buffer                                          
[deoplete]     len(self.vim.current.buffer))                                                                                                                                      
[deoplete]     len(self.vim.current.buffer))                                                                                                                                      
[deoplete]   File "/home/developer-01/.vim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 239, in buffer_slice                                         
[deoplete]   File "/home/developer-01/.vim/plugged/deoplete-ternjs/rplugin/python3/deoplete/sources/ternjs.py", line 239, in buffer_slice                                         
[deoplete]     text += buf[pos] + '\n'                                                                                                                                            
[deoplete]     text += buf[pos] + '\n'                                                                                                                                            
[deoplete]   File "/usr/local/lib/python3.4/dist-packages/neovim/api/buffer.py", line 45, in __getitem__                                                                          
[deoplete]   File "/usr/local/lib/python3.4/dist-packages/neovim/api/buffer.py", line 45, in __getitem__                                                                          
[deoplete]     return self.request('nvim_buf_get_lines', i, i + 1, True)[0]                                                                                                       
[deoplete]     return self.request('nvim_buf_get_lines', i, i + 1, True)[0]                                                                                                       
[deoplete]   File "/usr/local/lib/python3.4/dist-packages/neovim/api/common.py", line 44, in request                                                                              
[deoplete]   File "/usr/local/lib/python3.4/dist-packages/neovim/api/common.py", line 44, in request                                                                              
[deoplete]     return self._session.request(name, self, *args, **kwargs)                                                                                                          
[deoplete]     return self._session.request(name, self, *args, **kwargs)                                                                                                          
[deoplete]   File "/usr/local/lib/python3.4/dist-packages/neovim/api/nvim.py", line 131, in request                                                                               
[deoplete]   File "/usr/local/lib/python3.4/dist-packages/neovim/api/nvim.py", line 131, in request                                                                               
[deoplete]     res = self._session.request(name, *args, **kwargs)                                                                                                                 
[deoplete]     res = self._session.request(name, *args, **kwargs)                                                                                                                 
[deoplete]   File "/usr/local/lib/python3.4/dist-packages/neovim/msgpack_rpc/session.py", line 98, in request                                                                     
[deoplete]   File "/usr/local/lib/python3.4/dist-packages/neovim/msgpack_rpc/session.py", line 98, in request                                                                     
[deoplete]     raise self.error_wrapper(err)                                                                                                                                      
[deoplete]     raise self.error_wrapper(err)                                                                                                                                      
[deoplete] neovim.api.nvim.NvimError: b'Index out of bounds'                                                                                                                      
[deoplete] neovim.api.nvim.NvimError: b'Index out of bounds'               

I was following this : https://www.gregjs.com/vim/2016/neovim-deoplete-jspc-ultisnips-and-tern-a-config-for-kickass-autocompletion/

Neovim : commit # ddab466 deoplete.nvim : commit # 523eebf deoplete-ternjs : commit # b0bf130

I'll bundle a config file later to properly demonstrate it.

Edit 1: Ok, cannot reproduce it in another project... so most likely the .tern-project is misconfigured, or I have to increase the ulimit of the dev machine... Will check tomorrow.

joaumg commented 7 years ago

Ok, after some hours playing with this, I got it working...

The ft of the file I was editing was javascript.jsx for some unknown reason (I'm not using JSX at all...). So adding the let g:tern#filetypes = [ ... 'javascript.jsx', ... ] got it working.

Lastly, I don't know if this will help @dbellavista and others, but double check ft, omnifunc, the .tern-project, .tern-config (if any) and :messages...

If it helps, you can see the tern-config I'm using: tern-config.

Kind regards.

alem0lars-yr commented 7 years ago

I have that problem (sometimes, not always) with:

I'm editing only plain javascript files. I still don't understand the cause.

@carlitux @joaumg Do you think that the missing javascript element in the g:tern#filetypes array could be the cause ?

joaumg commented 7 years ago

@alem0lars-yoroi most likely not, since a glance at the source code of deoplete-ternjs adds the ft javascript at the python level : https://github.com/carlitux/deoplete-ternjs/blob/b0bf130c6ab0333838ae6765372969555a526bbc/rplugin/python3/deoplete/sources/ternjs.py#L52

This is a quite hard to debug issue...

carlitux commented 7 years ago

@joaumg let me try adding that filetypes and test.

Edit: if you can provide more info to test, maybe something is not collecting well the position.

joaumg commented 7 years ago

@carlitux , could you guide me into debugging the python part ? Could I just import pdb ? Or use import pprint ?

Also what intrigues me are how start and end are defined: https://github.com/carlitux/deoplete-ternjs/blob/master/rplugin/python3/deoplete/sources/ternjs.py#L264-L267

carlitux commented 7 years ago

@joaumg about debuggin use deoplete feature self.debug() and self.info() methods

about the second one really I don't know looks like is something how tern works most of this code is based on tern_for_vim https://github.com/ternjs/tern_for_vim/blob/master/script/tern.py#L177

joaumg commented 7 years ago

@carlitux sorry for the major delay, I've added the self.debug() and self.info() with params before the text += buf[pos] + '\n' but it didn't get printed into :messages ...

Does it write to a different buffer/view/file ?

carlitux commented 7 years ago

@joaumg please read this will help https://github.com/Shougo/deoplete.nvim/blob/master/doc/deoplete.txt#L1393

maybe you have to read all the doc to see how debug

carlitux commented 7 years ago

Assuming there is a race condition on buf size and end, start uses len(buf)

Please reopen this if there are some weird results on autocompletes.