Vim exits visual mode when loclist is open
When there are some errors and loclist is open, I can't use visual mode for longer than a fraction of a second. It seems as if ale was doing something constantly.
My ale config:
let g:ale_open_list = 1
Steps to reproduce:
- Use the above setting
- Open any file with some code
- Introduce an error to that code (loclist window should show up)
- Enter visual mode
- Wait a fraction of a second
Expected result:
- Vim stays in visual mode
Actual result:
- Vim switches to normal mode
Additional notes:
- Replace and insert modes seem to work fine. Visual mode is the only problematic mode
- The issue occurs only when there are errors in loclist window
me too! @w0rp 😣
Looks like this is caused by these lines: https://github.com/w0rp/ale/blob/master/plugin/ale.vim#L64 https://github.com/w0rp/ale/blob/d7ed49f84964aebdaa180b553e83943cd85c5d20/autoload/ale/list.vim#L38
Ale is set to trigger on BufEnter (as default).
When ale_open_list is set, after linting is done, lopen is called to open location list. To bring focus back to the original window, wincmd p is called. This is a BufEnter event and triggers ale again. Causing an infinite loop.
Incidentally, wincmd p causes vim to get out of visual mode.
@megapctr @kaidiren Setting this in vimrc should temporarily solve the problem.
let g:ale_lint_on_save = 1
let g:ale_lint_on_enter = 0
@w0rp What do you think of changing
https://github.com/w0rp/ale/blob/master/plugin/ale.vim#L64
to just BufRead. May be rename ale_lint_on_enter to ale_lint_on_read then?
It would need some testing to make sure that error checking happens when you look at buffer after changes have been made to it via some other tool, say git checkout, etc. If BufEnter is needed, then some more work will need to be done to handle this edge case.