fix(undo): u_savecommon uses wrong buffer

Problem: u_savecommon with reload = true wrongly uses curbuf.

Solution: use buf. Fix comments.
This commit is contained in:
Sean Dewar
2026-02-17 00:06:03 +00:00
parent 16bf7652b7
commit ce9dbd398b
2 changed files with 22 additions and 3 deletions

View File

@@ -382,7 +382,7 @@ int u_savecommon(buf_T *buf, linenr_T top, linenr_T bot, linenr_T newbot, bool r
u_entry_T *prev_uep;
linenr_T size = bot - top - 1;
// If curbuf->b_u_synced == true make a new header.
// If buf->b_u_synced == true make a new header.
if (buf->b_u_synced) {
// Need to create new entry in b_changelist.
buf->b_new_change = true;
@@ -401,7 +401,7 @@ int u_savecommon(buf_T *buf, linenr_T top, linenr_T bot, linenr_T newbot, bool r
}
// If we undid more than we redid, move the entry lists before and
// including curbuf->b_u_curhead to an alternate branch.
// including buf->b_u_curhead to an alternate branch.
u_header_T *old_curhead = buf->b_u_curhead;
if (old_curhead != NULL) {
buf->b_u_newhead = old_curhead->uh_next.ptr;
@@ -608,7 +608,7 @@ int u_savecommon(buf_T *buf, linenr_T top, linenr_T bot, linenr_T newbot, bool r
buf->b_u_newhead->uh_entry = uep;
if (reload) {
// buffer was reloaded, notify text change subscribers
curbuf->b_u_newhead->uh_flags |= UH_RELOAD;
buf->b_u_newhead->uh_flags |= UH_RELOAD;
}
buf->b_u_synced = false;
undo_undoes = false;