vim-patch:9.1.0113: duplicate code when cleaning undo stack

Problem:  duplicate code when cleaning undo stack
Solution: refactor undo cleanup into a single public function

related: vim/vim#13928

9071ed8107

Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
zeertzjq
2024-02-16 06:56:12 +08:00
parent c1fa8789c1
commit 163add40b8
4 changed files with 27 additions and 20 deletions

View File

@@ -843,8 +843,9 @@ void buf_freeall(buf_T *buf, int flags)
ml_close(buf, true); // close and delete the memline/memfile
buf->b_ml.ml_line_count = 0; // no lines in buffer
if ((flags & BFA_KEEP_UNDO) == 0) {
u_blockfree(buf); // free the memory allocated for undo
u_clearall(buf); // reset all undo information
// free the memory allocated for undo
// and reset all undo information
u_clearallandblockfree(buf);
}
syntax_clear(&buf->b_s); // reset syntax info
buf->b_flags &= ~BF_READERR; // a read error is no longer relevant