File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,11 @@ 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+ " If the buffer is completely empty, there's nothing to do
134+ return
135+ endif
136+
132137 let l: Style_value = s: plugin .Flag (' clang_format_style' )
133138 if type (l: Style_value ) is # type (' ' )
134139 let l: style = l: Style_value
Original file line number Diff line number Diff line change @@ -181,3 +181,10 @@ current buffer.
181181
182182The -assume-filename arg passed above is also related, used by the clang-format
183183tool to detect any custom style rules particular to the current file.
184+
185+
186+ Bug #102. When the buffer is empty, clang-format does _not_ return a cursor
187+ position
188+
189+ @clear
190+ :FormatCode clang-format
You can’t perform that action at this time.
0 commit comments