Skip to content

Commit 685f481

Browse files
committed
Do not call clang-format if buffer is empty.
closes #102 Signed-off-by: Wolfgang E. Sanyer <WolfgangSanyer@Google.com>
1 parent 0e1fa55 commit 685f481

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

autoload/codefmt/clangformat.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ function! codefmt#clangformat#GetFormatter() abort
129129
""
130130
" Reformat buffer with clang-format, only targeting [ranges] if given.
131131
function l:formatter.FormatRanges(ranges) abort
132+
if line('$') == 1 && getline(1) == ''
133+
" the buffer is empty, bail out since there is nothing to format
134+
return
135+
endif
132136
let l:Style_value = s:plugin.Flag('clang_format_style')
133137
if type(l:Style_value) is# type('')
134138
let l:style = l:Style_value

0 commit comments

Comments
 (0)