wfxr / minimap.vim

📡 Blazing fast minimap / scrollbar for vim, powered by code-minimap written in Rust.
MIT License
1.19k stars 23 forks source link

stateful_lines - errors when minimap is closed #119

Closed ZNielsen closed 2 years ago

ZNielsen commented 2 years ago

Seeing an issue with ZZ. Repro: Two buffers are open, both have unsaved changes, ZZ

Seeing: The first buffer closes, and the minimap closes with it. Then a errors appear when attempting to s:source_move for the second buffer.

I think this is because the minimap is closing down when it shouldn't be. There's still another buffer open.

Originally posted by @ZNielsen in https://github.com/wfxr/minimap.vim/issues/118#issuecomment-946051945

ZNielsen commented 2 years ago

Mitigated by checking for existence before indexing, but that doesn't solve the problem of the minimap closing when it shouldn't. if !exists('s:win_info["mmwinid"]') || win_getid() == s:win_info['mmwinid'] in s:source_win_scroll() and s:source_move()

ZNielsen commented 2 years ago

This is due to the interaction between how we handle QuitPre and how vim stops the quit if there's a different buffer with unsaved changes. We have already killed the minimap in expectation of the vim session ending, but vim bails out due to the unsaved buffer. Possible solutions:

1) Switch over to using VimLeavePre. Not as simple as just changing the autocmd, but this might be the 'best' way. 2) Detect when quitting has been abandoned, reopen the minimap. 3) Prevent the errors from popping up in this case - I think unsetting the autocmds might be enough for this.

ZNielsen commented 2 years ago

This is a bigger issue - we are seeing these errors any time the minimap is closed. Need to add handling for that.