diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/undo.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/nvim/undo.c b/src/nvim/undo.c index b36d1ac3ec..539d42765d 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -243,7 +243,7 @@ int u_save(linenr_T top, linenr_T bot) */ int u_savesub(linenr_T lnum) { - return u_savecommon(lnum - 1, lnum + 1, lnum + 1, FALSE); + return u_savecommon(lnum - 1, lnum + 1, lnum + 1, false); } /* @@ -254,7 +254,7 @@ int u_savesub(linenr_T lnum) */ int u_inssub(linenr_T lnum) { - return u_savecommon(lnum - 1, lnum, lnum + 1, FALSE); + return u_savecommon(lnum - 1, lnum, lnum + 1, false); } /* @@ -3043,8 +3043,14 @@ u_header_T *u_force_get_undo_header(buf_T *buf) } // Create the first undo header for the buffer if (!uhp) { - // TODO(timeyyy): there would be a better way to do this! - u_save_cursor(); + // Undo is normally invoked in change code, which already has swapped + // curbuf. + buf_T *save_curbuf = curbuf; + curbuf = buf; + // Args are tricky: this means replace empty range by empty range.. + u_savecommon(0, 1, 1, true); + curbuf = save_curbuf; + uhp = buf->b_u_curhead; if (!uhp) { uhp = buf->b_u_newhead; |