vimwiki

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

commit 1bea2ce40ad3993387e9bc9ade25c2a90a31d8a2
parent 2141fde8b8c68ce8c6136673890acc354dc78f8c
Author: Tobias Mersmann <Mersmann.Tobias@gmail.com>
Date:   Sun, 18 Jul 2021 12:39:52 +0200

fix(update_listing_in_buffer): don't update listing if there are no changes

Before updating a listing, check if the update differs from the existing state.
Only then update the buffer, otherwise return early.

Initial reasoning: If `let g:vimwiki_auto_toc = 1` is set, saving a buffer would always update
the `contents`-section, even if there were no updates in this section. This lead to undesired
undo-behavior.

NOTE: this fix was only tested for the toc-listing.
Diffstat:
Mautoload/vimwiki/base.vim | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim @@ -1521,6 +1521,12 @@ function! vimwiki#base#update_listing_in_buffer(Generator, start_header, " them right back. 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(), "")) + return + endif + silent exe 'keepjumps ' . start_lnum.','.string(end_lnum - 1).'delete _' let &l:foldenable = foldenable_save let lines_diff = 0 - (end_lnum - start_lnum)