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.
This commit is contained in:
committed by
Tinmarino
parent
2141fde8b8
commit
1bea2ce40a
@@ -1521,6 +1521,12 @@ function! vimwiki#base#update_listing_in_buffer(Generator, start_header,
|
|||||||
" them right back.
|
" them right back.
|
||||||
let foldenable_save = &l:foldenable
|
let foldenable_save = &l:foldenable
|
||||||
setlocal nofoldenable
|
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 _'
|
silent exe 'keepjumps ' . start_lnum.','.string(end_lnum - 1).'delete _'
|
||||||
let &l:foldenable = foldenable_save
|
let &l:foldenable = foldenable_save
|
||||||
let lines_diff = 0 - (end_lnum - start_lnum)
|
let lines_diff = 0 - (end_lnum - start_lnum)
|
||||||
|
|||||||
Reference in New Issue
Block a user