List index out of range error when stripping modified lines
tyilo opened this issue · comments
This is the only contents of my .vimrc
:
call plug#begin('~/.vim/plugged')
Plug 'ntpeters/vim-better-whitespace'
call plug#end()
let g:strip_whitespace_on_save=1
let g:strip_only_modified_lines=1
When changing a line with trailing whitespace in a file and then saving, I get the following error:
Error detected while processing function <SNR>18_StripWhitespaceOnSave:
line 8:
E684: list index out of range: 1
E116: Invalid arguments for function <SID>DetectWhitespace(r[0], r[1])
E684: list index out of range: 1
E116: Invalid arguments for function <SID>DetectWhitespace(r[0], r[1])
E684: list index out of range: 1
E116: Invalid arguments for function <SID>DetectWhitespace(r[0], r[1])
E684: list index out of range: 1
E116: Invalid arguments for function <SID>DetectWhitespace(r[0], r[1])
E684: list index out of range: 1
E116: Invalid arguments for function <SID>DetectWhitespace(r[0], r[1])
E684: list index out of range: 1
E116: Invalid arguments for function <SID>DetectWhitespace(r[0], r[1])
E684: list index out of range: 1
E116: Invalid arguments for function <SID>DetectWhitespace(r[0], r[1])
E684: list index out of range: 1
E116: Invalid arguments for function <SID>DetectWhitespace(r[0], r[1])
E684: list index out of range: 1
E116: Invalid arguments for function <SID>DetectWhitespace(r[0], r[1])
E684: list index out of range: 1
E116: Invalid arguments for function <SID>DetectWhitespace(r[0], r[1])
E684: list index out of range: 1
Hi @tyilo. I’m afraid I can’t reproduce this bug with the information you currently provide. What’s your vim version? Plugin version? Are you sure that’s all you have in your vimrc, not even set nocp
? or let g:strip_whitespace_confirm=0
? Because I’m not sure the plugin would even load in compatible
mode.
Version:
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun 5 2019 14:31:35)
Included patches: 1-1467
Compiled by Arch Linux
Huge version with GTK3 GUI. Features included (+) or not (-):
+acl +extra_search +mouse_netterm -tag_old_static
+arabic -farsi +mouse_sgr -tag_any_white
+autocmd +file_in_path -mouse_sysmouse +tcl/dyn
+autochdir +find_in_path +mouse_urxvt +termguicolors
-autoservername +float +mouse_xterm +terminal
+balloon_eval +folding +multi_byte +terminfo
+balloon_eval_term -footer +multi_lang +termresponse
+browse +fork() -mzscheme +textobjects
++builtin_terms +gettext +netbeans_intg +textprop
+byte_offset -hangul_input +num64 +timers
+channel +iconv +packages +title
+cindent +insert_expand +path_extra +toolbar
+clientserver +job +perl/dyn +user_commands
+clipboard +jumplist +persistent_undo +vartabs
+cmdline_compl +keymap +postscript +vertsplit
+cmdline_hist +lambda +printer +virtualedit
+cmdline_info +langmap +profile +visual
+comments +libcall +python/dyn +visualextra
+conceal +linebreak +python3/dyn +viminfo
+cryptv +lispindent +quickfix +vreplace
+cscope +listcmds +reltime +wildignore
+cursorbind +localmap +rightleft +wildmenu
+cursorshape +lua/dyn +ruby/dyn +windows
+dialog_con_gui +menu +scrollbind +writebackup
+diff +mksession +signs +X11
+digraphs +modify_fname +smartindent -xfontset
+dnd +mouse +startuptime +xim
-ebcdic +mouseshape +statusline -xpm
+emacs_tags +mouse_dec -sun_workshop +xsmp_interact
+eval +mouse_gpm +syntax +xterm_clipboard
+ex_extra -mouse_jsbterm +tag_binary -xterm_save
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "/etc/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
defaults file: "$VIMRUNTIME/defaults.vim"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/libffi-3.2.1/include -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/uuid -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/gio-unix-2.0 -I/usr/include/libdrm -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -pthread -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.30/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/usr/local/lib -Wl,--as-needed -o vim -lgtk-3 -lgdk-3 -lz -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lelf -lnsl -lacl -lattr -lgpm -ldl -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.30/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib -L/usr/lib/perl5/5.30/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm
Plugin version: f5726c4
Are you sure that’s all you have in your vimrc, not even
set nocp
? orlet g:strip_whitespace_confirm=0
?
It's literally the only thing in my vimrc, no set nocp
.
Adding set nocp
, doesn't change anything either.
The problem was that I was using fish as my shell.
Adding the following to my vimrc, fixed it:
set shell=bash
Even with shell=fish
it doesn’t seem to trigger the same problem. I use the following to only load vim-better-whitespace with the options you specify:
> cat test_vimrc
set nocp
set shell=fish
let g:strip_whitespace_on_save=1
let g:strip_only_modified_lines=1
set rtp+=$HOME/.vim/bundle/vim-better-whitespace
> vim -u test_vimrc ~/.vim/bundle/vim-better-whitespace/whitespace_examples.txt
And modifying any whitespace line behaves like expected, with a confirmation prompt etc. I’m using a (very slightly) older vim:
VIM - Vi IMproved 8.1 (2018 May 18, compiled Mar 18 2019 17:20:59)
Included patches: 1-1017
If I don’t have nocp
then a line continuation causes a bug while parsing the plugin file. This makes me suspect that maybe your plugin is not really at the version it says it is? Is it a submodule or something like that? If so, can you try a git reset --hard
in the plugin directory? Or can you otherwise re-install the plugin just to double-check?
Ah, the problem was that I had the following alias in my fish config:
alias diff="colordiff -u"
See #110
Resolved in #121