vimwiki

Personal wiki for vim
git clone https://github.com/vimwiki/vimwiki.git
Log | Files | Refs | README | LICENSE

commit ecce18449397535adf0523fc5be58c0cb2ebfe42
parent 1bea2ce40ad3993387e9bc9ade25c2a90a31d8a2
Author: Tinmarino <tinmarino@gmail.com>
Date:   Sat, 18 Dec 2021 11:53:59 -0300

VimwikiTOC: update-listing in buffer more lazy (after #1155)

Diffstat:
Mautoload/vimwiki/base.vim | 14++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim @@ -1476,12 +1476,12 @@ function! vimwiki#base#update_listing_in_buffer(Generator, start_header, " Clause: Check if the listing is already there let already_there = 0 - + " -- Craft header regex to search for let header_level = 'rxH' . a:header_level . '_Template' let header_rx = '\m^\s*'.substitute(vimwiki#vars#get_syntaxlocal(header_level), \ '__Header__', a:start_header, '') .'\s*$' - let start_lnum = 1 + " -- Search fr the header in all file while start_lnum <= line('$') if getline(start_lnum) =~# header_rx let already_there = 1 @@ -1489,7 +1489,6 @@ function! vimwiki#base#update_listing_in_buffer(Generator, start_header, endif let start_lnum += 1 endwhile - if !already_there && !a:create return endif @@ -1505,6 +1504,9 @@ function! vimwiki#base#update_listing_in_buffer(Generator, start_header, let is_fold_closed = 1 let lines_diff = 0 + " Generate listing content + let a_list = a:Generator.f() + " Set working range according to listing presence if already_there " Delete the old listing @@ -1522,8 +1524,8 @@ function! vimwiki#base#update_listing_in_buffer(Generator, start_header, let foldenable_save = &l:foldenable setlocal nofoldenable - " don't update file if there are no changes - if (join(getline(start_lnum + 2, end_lnum - 1), "") == join(a:Generator.f(), "")) + " Clause: don't update file if there are no changes + if (join(getline(start_lnum + 2, end_lnum - 1), '') == join(a_list, '')) return endif @@ -1558,7 +1560,7 @@ function! vimwiki#base#update_listing_in_buffer(Generator, start_header, let lines_diff += 1 endfor endif - for string in a:Generator.f() + for string in a_list keepjumps call append(start_lnum - 1, string) let start_lnum += 1 let lines_diff += 1