vim-syntastic / syntastic

Syntax checking hacks for vim
Do What The F*ck You Want To Public License
11.3k stars 1.14k forks source link

lopen then lclose cause E242 error #2279

Closed xuxinx closed 5 years ago

xuxinx commented 5 years ago

steps to reproduce the bug

  1. prepare test files
    • .test_vimrc
      
      set nocompatible

filetype off set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Plugin 'VundleVim/Vundle.vim' Plugin 'vim-syntastic/syntastic' call vundle#end() filetype plugin indent on

let g:syntastic_always_populate_loc_list = 1 let g:syntastic_auto_loc_list = 1 let g:syntastic_check_on_wq = 1 let g:syntastic_sh_checkers = ['shellcheck']

- test.sh
```sh
aa=1
  1. do test
    • vim -u .test_vimrc test.sh
    • :w
    • :lopen
    • :lclose

Error

Error detected while processing function <SNR>18_BufEnterHook[12]..78[20]..4[2]..5[5]..66:
line    6:
E242: Can't split a window while closing another

the version of Vim

:ver
VIM - Vi IMproved 8.1 (2018 May 18, compiled Aug 22 2019 04:02:38)
macOS version
Included patches: 1-1900
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               +cmdline_compl     +emacs_tags        +insert_expand     +modify_fname      +netbeans_intg     +ruby              +termguicolors     +visualextra
+arabic            +cmdline_hist      +eval              +job               +mouse             +num64             +scrollbind        +terminal          +viminfo
+autocmd           +cmdline_info      +ex_extra          +jumplist          -mouseshape        +packages          +signs             +terminfo          +vreplace
+autochdir         +comments          +extra_search      +keymap            +mouse_dec         +path_extra        +smartindent       +termresponse      +wildignore
-autoservername    +conceal           -farsi             +lambda            -mouse_gpm         +perl              -sound             +textobjects       +wildmenu
-balloon_eval      +cryptv            +file_in_path      +langmap           -mouse_jsbterm     +persistent_undo   +spell             +textprop          +windows
+balloon_eval_term +cscope            +find_in_path      +libcall           +mouse_netterm     +postscript        +startuptime       +timers            +writebackup
-browse            +cursorbind        +float             +linebreak         +mouse_sgr         +printer           +statusline        +title             -X11
++builtin_terms    +cursorshape       +folding           +lispindent        -mouse_sysmouse    +profile           -sun_workshop      -toolbar           -xfontset
+byte_offset       +dialog_con        -footer            +listcmds          +mouse_urxvt       -python            +syntax            +user_commands     -xim
+channel           +diff              +fork()            +localmap          +mouse_xterm       +python3           +tag_binary        +vartabs           -xpm
+cindent           +digraphs          +gettext           +lua               +multi_byte        +quickfix          -tag_old_static    +vertsplit         -xsmp
-clientserver      -dnd               -hangul_input      +menu              +multi_lang        +reltime           -tag_any_white     +virtualedit       -xterm_clipboard
+clipboard         -ebcdic            +iconv             +mksession         -mzscheme          +rightleft         -tcl               +visual            -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim
     -lncurses -liconv -lintl -framework AppKit  -L/usr/local/opt/lua/lib -llua5.3 -mmacosx-version-min=10.13 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/
5.30.0/lib/perl5/5.30.0/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin -
lpython3.7m -framework CoreFoundation  -lruby.2.6

also tried version 8.1.1800

the version of syntastic

Syntastic version: 3.9.0-44 (Vim 801, Darwin)
xuxinx commented 5 years ago

remove let g:syntastic_auto_loc_list = 1 works

lcd047 commented 5 years ago

"Doctor, it hurts when I do X!"

Back when the relevant part of syntastic core was written Vim plugins had no way to tell whether a given window was associated to a loclist, and if it did, what buffer was its owner. A plugin could navigate back and forth through the loclist stack, but it couldn't tell whether the stack has changed when it wasn't looking, or what was the current pointer in said stack. And so on. For this reason syntastic had to invent workarounds for all sorts of limitations, and of course the workarounds only worked in (optimistically) maybe 95% of cases. Another consequence was that in order to do internal bookkeeping syntastic had to invent wrappers around standard Vim commands. F.i. to open the error window you were supposed to run :Errors, not :lopen, and then you were supposed to refrain from messing with the loclist stack. If you run :lopen when the error window is already open you'll override syntastic's idea of state with something else.

Now, in more recent times Vim added features that lifted many (not all) of the limitations relevant to syntastic. However I haven't kept up with Vim development for quite a while now, so syntastic is still using the old workarounds, even though much better solutions are now possible. Patches are welcome. Or you could switch to ALE, which offers a more modern approach, and is actively maintained.

xuxinx commented 5 years ago

Got it. Thanks!