From 7edeedb8b9ca35250b66edb7e33ff7c545e273d3 Mon Sep 17 00:00:00 2001 From: Patrick Boettcher
Date: Wed, 24 Jul 2019 10:07:25 +0200 Subject: [PATCH] indent: fix end-of-control-block indent if block is empty --- indent/cmake.vim | 4 +++- test/if-endif-indent.cmake | 2 ++ test/if-endif-indent.cmake.html.ref | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 test/if-endif-indent.cmake create mode 100644 test/if-endif-indent.cmake.html.ref diff --git a/indent/cmake.vim b/indent/cmake.vim index 4a0b356..57343c4 100644 --- a/indent/cmake.vim +++ b/indent/cmake.vim @@ -105,7 +105,9 @@ fun! CMakeGetIndent(lnum) if previous_line =~? s:cmake_indent_begin_regex " control begin block let ind = ind + shiftwidth() - elseif this_line =~? s:cmake_indent_end_regex " control end block + endif + + if this_line =~? s:cmake_indent_end_regex " control end block let ind = ind - shiftwidth() elseif this_line =~? s:cmake_indent_comment_line if g:cmake_indent_align_comments_to_first_column == 1 diff --git a/test/if-endif-indent.cmake b/test/if-endif-indent.cmake new file mode 100644 index 0000000..1c4eb32 --- /dev/null +++ b/test/if-endif-indent.cmake @@ -0,0 +1,2 @@ +if(HELLO) +endif() diff --git a/test/if-endif-indent.cmake.html.ref b/test/if-endif-indent.cmake.html.ref new file mode 100644 index 0000000..062a963 --- /dev/null +++ b/test/if-endif-indent.cmake.html.ref @@ -0,0 +1,6 @@ +
++if(HELLO) +endif() ++