simnalamburt / vim-mundo

:christmas_tree: Vim undo tree visualizer

Home Page:https://simnalamburt.github.io/vim-mundo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when opening mundo if undo history is in `undofile`/`undodir`

calebeby opened this issue · comments

Here are the steps I did:

  1. Add to vim config:
    set undodir=~/.vimdid
    set undofile
    
  2. Edit a file, creating some edit history: nvim ~/.vimrc
  3. Close file
  4. Open file again
  5. Open undo tree in file

Then this error pops up:

Error detected while processing function <SNR>75_MundoRefreshDelayed[23]..<SNR>75_MundoRenderPreview[5]..<SNR>75_MundoPythonRestoreView[17]..<SNR>75_MundoPython[1]..provider#python3#Call:                                      
line   18:                                                                                                                                                                                                                       
Error invoking 'python_execute' on channel 11 (python3-script-host):                                                                                                                                                             
Traceback (most recent call last):                                                                                                                                                                                               
  File "<string>", line 1, in <module>                                                                                                                                                                                           
  File "/home/caleb/dotfiles/vim/plugged/vim-mundo/autoload/mundo.py", line 187, in MundoRenderPreview                                                                                                                           
    util._output_preview_text(nodesData.preview_diff(node_before, node_after))                                                                                                                                                   
  File "/home/caleb/dotfiles/vim/plugged/vim-mundo/autoload/mundo/node.py", line 197, in preview_diff                                                                                                                            
    before_lines = self._get_lines(before)                                                                                                                                                                                       
  File "/home/caleb/dotfiles/vim/plugged/vim-mundo/autoload/mundo/node.py", line 121, in _get_lines                                                                                                                              
    util._undo_to(n)                                                                                                                                                                                                             
  File "/home/caleb/dotfiles/vim/plugged/vim-mundo/autoload/mundo/util.py", line 50, in _undo_to                                                                                                                                 
    vim().command('silent undo %d' % int(n))                                                                                                                                                                                     
  File "/home/caleb/.local/lib/python3.8/site-packages/pynvim/api/nvim.py", line 287, in command                                                                                                                                 
    return self.request('nvim_command', string, **kwargs)                                                                                                                                                                        
  File "/home/caleb/.local/lib/python3.8/site-packages/pynvim/api/nvim.py", line 182, in request                                                                                                                                 
    res = self._session.request(name, *args, **kwargs)                                                                                                                                                                           
  File "/home/caleb/.local/lib/python3.8/site-packages/pynvim/msgpack_rpc/session.py", line 102, in request                                                                                                                      
    raise self.error_wrapper(err)                                                                                                                                                                                                
pynvim.api.common.NvimError: Vim(undo):E830: Undo number 2 not found

I repeatedly press <esc> to close the error message and it keeps popping up, exactly the same, with the same undo number in the message.

If I switch to the editor view and make edits to the file, the undo tree is refreshed and I can go back to the undo tree without errors. It shows all the previous history correctly.

Python information in :checkhealth:

## Python 3 provider (optional)
  - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.
  - INFO: Multiple python3 executables found.  Set `g:python3_host_prog` to avoid surprises.
  - INFO: Executable: /usr/bin/python3
  - INFO: Other python executable: /home/linuxbrew/.linuxbrew/bin/python3
  - INFO: Python version: 3.8.10
  - INFO: pynvim version: 0.4.3
  - OK: Latest pynvim is installed.

Let me know if there's any more information that would help diagnose the issue!

Can confirm, with a minimal vimrc

set nocompatible

call plug#begin('~/.vim/bundle')

Plug 'https://github.com/tpope/vim-sensible'
Plug 'https://github.com/simnalamburt/vim-mundo'

call plug#end()

You don't need to even write or close the file to trigger the error.

git bisect shows that it was broken by c0d814b from #122.

The workaround is just manually checkout the previous working commit in the plugin directory (assuming a plugin manager): 595ee33

Since every :PlugUpdate breaks this again, a slightly more permanent fix is to use my fork which I will keep at 595ee33 until this issue is fixed:

Plug 'TamaMcGlinn/vim-mundo'

I will delete my fork when this issue is fixed, so you get an error and will know to switch back.

Thank you @simnalamburt, works great!