-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
Error on :wq
#215
Comments
Any thoughts/activities on this? I'm experiencing the same issue here |
Hi All, Could you please post the output of thanks :) |
Would be great to know the |
@mitermayer This happens on my personal machine, from which I'm away right now. Will be posting the version info here in two or three hours |
vim: 8.2 |
Thanks! Will upgrade my vim to those versions and try it out! looks like there could be some upstream changes in |
Greetings, fellow If this helps at all, doing ErrorError detected while processing function <lambda>6[1]..<SNR>176_onExit:
line 3:
E684: list index out of range: -1
E15: Invalid expression: a:out[len(a:out) - 1] Diagnostic Info$ uname -r
4.19.0-8-amd64
$ lsb_release -cs
buster
$ nvim --version
NVIM v0.3.4
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -g -O2 -fdebug-prefix-map=/build/neovim-RiUqEm/neovim-0.3.4=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=1 -DDISABLE_LOG -Wdate-time -D_FORTIFY_SOURCE=1 -Wconversion -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -Wno-array-bounds -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim-RiUqEm/neovim-0.3.4/build/config -I/build/neovim-RiUqEm/neovim-0.3.4/src -I/usr/include -I/build/neovim-RiUqEm/neovim-0.3.4/build/src/nvim/auto -I/build/neovim-RiUqEm/neovim-0.3.4/build/include
Compiled by [email protected]
Features: +acl +iconv -jemalloc +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info
~/.vim/plugged/vim-prettier $ git fetch --all; git status
Fetching origin
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean |
Hi, NVIM v0.5.0-445-gca02db1f9
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-5 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/travis/build/neovim/bot-ci/build/neovim/build/config -I/home/travis/build/neovim/bot-ci/build/neovim/src -I/home/travis/build/neovim/bot-ci/build/neovim/.deps/usr/include -I/usr/include -I/home/travis/build/neovim/bot-ci/build/neovim/build/src/nvim/auto -I/home/travis/build/neovim/bot-ci/build/neovim/build/include
Compiled by travis@travis-job-41e98c7d-18cc-46e0-90e2-721b8f0d476a
Features: +acl +iconv +tui |
I'm also seeing the same issue. Error only crops up when vim-prettier is configured to format on save. As @acidDrain said above, this is not an issue when ErrorError detected while processing function <lambda>4[1]..<SNR>108_onExit:
line 3:
E684: list index out of range: -1
E15: Invalid expression: a:out[len(a:out) - 1] Diagnostic info$ uname -r
5.3.0-46-generic
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
$ nvim --version
NVIM v0.3.8
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -g -O2 -fdebug-prefix-map=/build/neovim-lpKDO8/neovim-0.3.8=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=1 -DDISABLE_LOG -Wdate-time -D_FORTIFY_SOURCE=1 -Wconversion -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -Wno-array-bounds -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim-lpKDO8/neovim-0.3.8/build/config -I/build/neovim-lpKDO8/neovim-0.3.8/src -I/usr/include -I/build/neovim-lpKDO8/neovim-0.3.8/build/src/nvim/auto -I/build/neovim-lpKDO8/neovim-0.3.8/build/include
Compiled by [email protected]
Features: +acl +iconv -jemalloc +tui |
I'm not 100% if this would be an acceptable solution, but just copying the diff --git a/autoload/prettier/job/async/neovim.vim b/autoload/prettier/job/async/neovim.vim
index 7f69f4e..35e5f82 100644
--- a/autoload/prettier/job/async/neovim.vim
+++ b/autoload/prettier/job/async/neovim.vim
@@ -42,6 +42,8 @@ endfunction
"
" note that somehow we exectuing both async and sync on nvim when using the autoformat
function! s:onExit(status, info, out, err) abort
+ if len(a:out) == 0 | return | endif
+
let l:currentBufferNumber = bufnr('%')
let l:isInsideAnotherBuffer = a:info.buf_nr != l:currentBufferNumber ? 1 : 0
let l:last = a:out[len(a:out) - 1] |
I can confirm that this fixes the issue for me on Neovim 0.4.3 without any apparent changes in Prettier's behavior. |
Please feel free to submit a PR and I can merge it |
:wq
NVIM v0.5.0-b39edb5 |
This fixed it for me. Wait for updating. |
This fixes prettier#215 by implementing the fix I've suggested in [my comment][0]. After [the suggestion to open a PR][1], here we are :) [0]: prettier#215 (comment) [1]: prettier#215 (comment)
Do you want to request a feature or report a bug?
bug
What is the current/expected behavior?
Current behavior
When I save and quit with
:wq
, I get the following error:Expected behavior
At least there should not be no error. It would be great if the file is formatted before quitting.
What version of
vim-prettier
are you using - (output of:PrettierVersion
) ?1.0.0-alpha
What version of
prettier
are you using - (output of:PrettierCliVersion
) ?1.18.2
What is your
prettier
executable path - (output of:PrettierCliPath
) ?prettier
Did this work in previous versions of vim-prettier and/or prettier ?
I have been getting this error for at least several months.
The cause of this error is the following part in
s:onExit
that runs when prettier process exists.The function is supposed to be run when prettier finishes executing but I suppose when I type
:wq
the prettier process exits even though it has not finished formatting yet. Thusa:out
can become empty array and thus causing index-out-of-range error.Possible fix and question
The error can be fixed by checking emptiness of the array before accessing the array. This checking is currently done below after the line causing the error, which I want to know why.
If I can simply move the lines below to the top of the function, then I will submit a PR so let me know what you think.
Though the emptiness check removes this error, it will not format the file because prettier has not finish the formatting at the moment of quitting. I am not sure how to realize this. Any idea?
The text was updated successfully, but these errors were encountered: