aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/prettier.vim5
1 files changed, 5 insertions, 0 deletions
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 _'