extmark: don't crash in RO buffer.

This commit is contained in:
Björn Linse
2019-11-16 11:05:56 +01:00
parent 6222cca36a
commit ebdf90e7d7
2 changed files with 16 additions and 4 deletions

View File

@@ -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;