aboutsummaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authormitermayer <mitermayer.reis@gmail.com>2017-12-28 10:40:12 -0800
committermitermayer <mitermayer.reis@gmail.com>2017-12-28 10:40:12 -0800
commitb78cf3e319ed03edc1b49a6aca50a9f618cc4af7 (patch)
treeed465e65e24fbe799433e59b97da721402daec0f /autoload
parent32a17f75035a428e6630765b6ff1aeed594bd22f (diff)
downloadvim-prettier-b78cf3e319ed03edc1b49a6aca50a9f618cc4af7.tar.xz
bugfix - making sure we do not replace content with empty buffer
Diffstat (limited to 'autoload')
-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 _'