From 77fca9080c88f43119087ac62643ca2288320d9b Mon Sep 17 00:00:00 2001 From: Ivan Tishchenko Date: Tue, 1 Dec 2015 22:41:50 +0300 Subject: [PATCH] Fix code review notes on 'norm zo': - Only issue 'zo' if there is any fold at all. - Correct possible bug, code was using 'start_lnum' var, but it was changed/incremented which could lead to wrong results. - Use bang with norm, to prevent user re-mapping interfere with standard ones. --- autoload/vimwiki/base.vim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim index 7968f86..4f56f59 100644 --- a/autoload/vimwiki/base.vim +++ b/autoload/vimwiki/base.vim @@ -1175,6 +1175,8 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header, let whitespaces_in_first_line = '' endif + let start_of_listing = start_lnum + " write new listing let new_header = whitespaces_in_first_line \ . substitute(g:vimwiki_rxH1_Template, @@ -1193,9 +1195,9 @@ function! vimwiki#base#update_listing_in_buffer(strings, start_header, endif " Open fold, if needed - if !is_fold_closed - exe start_lnum - norm zo + if !is_fold_closed && foldclosed(start_of_listing) + exe start_of_listing + norm! zo endif if is_cursor_after_listing