From b78cf3e319ed03edc1b49a6aca50a9f618cc4af7 Mon Sep 17 00:00:00 2001 From: mitermayer Date: Thu, 28 Dec 2017 10:40:12 -0800 Subject: bugfix - making sure we do not replace content with empty buffer --- autoload/prettier.vim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/autoload/prettier.vim b/autoload/prettier.vim index c929927..7325dfa 100644 --- a/autoload/prettier.vim +++ b/autoload/prettier.vim @@ -222,6 +222,11 @@ function! s:Apply_Prettier_Format(lines, startSelection, endSelection) abort let l:winview = winsaveview() let l:newBuffer = s:Get_New_Buffer(a:lines, a:startSelection, a:endSelection) + " we should not replace contents if the newBuffer is empty + if empty(l:newBuffer) + return + endif + " delete all lines on the current buffer silent! execute len(l:newBuffer) . ',' . line('$') . 'delete _' -- cgit v1.3