Skip to content

List index out of range error when stripping modified lines #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tyilo opened this issue Jun 12, 2019 · 6 comments
Closed

List index out of range error when stripping modified lines #109

tyilo opened this issue Jun 12, 2019 · 6 comments
Labels
bug waiting for merge a fix is proposed and needs to be reviewed

Comments

@tyilo
Copy link

tyilo commented Jun 12, 2019

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
@Cimbali
Copy link
Collaborator

Cimbali commented Jun 12, 2019

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.

@tyilo
Copy link
Author

tyilo commented Jun 12, 2019

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 ? or let 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.

@tyilo
Copy link
Author

tyilo commented Jun 12, 2019

The problem was that I was using fish as my shell.
Adding the following to my vimrc, fixed it:

set shell=bash

@Cimbali
Copy link
Collaborator

Cimbali commented Jun 13, 2019

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?

tyilo added a commit to tyilo/vim-better-whitespace that referenced this issue Jun 13, 2019
@tyilo
Copy link
Author

tyilo commented Jun 13, 2019

Ah, the problem was that I had the following alias in my fish config:

alias diff="colordiff -u"

See #110

Cimbali added a commit to Cimbali/vim-better-whitespace that referenced this issue Jun 14, 2019
Ignores aliases set in the shell by default, which closes ntpeters#109
Cimbali added a commit to Cimbali/vim-better-whitespace that referenced this issue Jun 14, 2019
Ignores aliases set in the shell by default, which closes ntpeters#109
Cimbali added a commit to Cimbali/vim-better-whitespace that referenced this issue Sep 16, 2019
Ignores aliases set in the shell by default, which closes ntpeters#109
@Cimbali Cimbali added bug waiting for merge a fix is proposed and needs to be reviewed labels Oct 21, 2019
Cimbali added a commit to Cimbali/vim-better-whitespace that referenced this issue Oct 23, 2019
Instead of diff which may be aliased in some way, e.g. diff.cmd
See ntpeters#121, ntpeters#111 and ntpeters#109.
@ntpeters
Copy link
Owner

Resolved in #121

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug waiting for merge a fix is proposed and needs to be reviewed
Projects
None yet
3 participants