diff --git a/autoload/codefmt/clangformat.vim b/autoload/codefmt/clangformat.vim index 542a3ab..0512e5b 100644 --- a/autoload/codefmt/clangformat.vim +++ b/autoload/codefmt/clangformat.vim @@ -129,6 +129,11 @@ function! codefmt#clangformat#GetFormatter() abort "" " Reformat buffer with clang-format, only targeting [ranges] if given. function l:formatter.FormatRanges(ranges) abort + if line('$') == 1 && getline(1) == '' + " If the buffer is completely empty, there's nothing to do + return + endif + let l:Style_value = s:plugin.Flag('clang_format_style') if type(l:Style_value) is# type('') let l:style = l:Style_value diff --git a/vroom/clangformat.vroom b/vroom/clangformat.vroom index 250b45b..424171e 100644 --- a/vroom/clangformat.vroom +++ b/vroom/clangformat.vroom @@ -181,3 +181,10 @@ current buffer. The -assume-filename arg passed above is also related, used by the clang-format tool to detect any custom style rules particular to the current file. + + +Bug #102. When the buffer is empty, clang-format does _not_ return a cursor +position + + @clear + :FormatCode clang-format