From a1a66c9a90190b8199c25337925452465be8bf9c Mon Sep 17 00:00:00 2001 From: mitermayer Date: Thu, 25 May 2017 17:11:28 -0700 Subject: bugfix: Making sure that when prettier fail to parse buffer we do not overwrite file with stdout output --- autoload/prettier.vim | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'autoload/prettier.vim') diff --git a/autoload/prettier.vim b/autoload/prettier.vim index 3ec6cfb..deb25a7 100644 --- a/autoload/prettier.vim +++ b/autoload/prettier.vim @@ -10,6 +10,12 @@ function! prettier#Prettier() abort if exec != -1 let l:stdout = split(system(exec . s:Get_Prettier_Exec_Args(), getbufline(bufnr('%'), 1, '$')), '\n') + " check system exit code + if v:shell_error + echohl WarningMsg | echom 'Prettier: failed to parse buffer.' | echohl NONE + return + endif + " delete all lines on the current buffer silent! execute 1 . ',' . line('$') . 'delete _' -- cgit v1.3