ntpeters / vim-better-whitespace

Better whitespace highlighting for Vim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Commit a05c728a causing index out of range on line 280

therealjumbo opened this issue · comments

The error I get:

Error detected while processing function 15_StripWhitespaceOnSave:
line   21:
E684: list index out of range: 1
E116: Invalid arguments for function 15_StripWhitespace

Which seems to be caused by this commit: a05c728#diff-5fc653188d2bdd71ad2b090f26711540

If I change that back to trim then that function returns a list longer than 1 item.

vi --version

NVIM v0.5.0-dev
Build type: RelWithDebInfo
Lua 5.1
Compilation: /usr/bin/x86_64-linux-gnu-gcc -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -DMIN_LOG_LEVEL=3 -Og -g -Wall -Wextr a -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLAR ATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim-GBaArp/neovim-0.5.0+ubuntu1+git201910172025-0785f8e-00e710e/build/config -I/build/neovim-GBaArp/neov im-0.5.0+ubuntu1+git201910172025-0785f8e-00e710e/src -I/build/neovim-GBaArp/neovim-0.5.0+ubuntu1+git201910172025-0785f8e-00e710e/.deps/usr/include -I/usr/include -I/build/neovim-GBaArp/neovi m-0.5.0+ubuntu1+git201910172025-0785f8e-00e710e/build/src/nvim/auto -I/build/neovim-GBaArp/neovim-0.5.0+ubuntu1+git201910172025-0785f8e-00e710e/build/include
Compiled by buildd@lcy01-amd64-029
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info

Do you want me to try to reproduce with a minimal vimrc/init.vim?

Ah thanks a lot ! I didn’t have time to look into it and I had seen it reproducible on some vim installs but not others, and only when the only changes were deleting lines... Turns out the substitute s:Trim() is at fault for not removing new lines when they are the only character in the string.

Replacing the \s with \_s in the s:Trim’s substitute() command seem to fix it. I’m committing and pushing this right now, and hopefully @ntpeters will have time to merge it soon.

I will test your PR: #121