vim-patch:8.1.1890: ml_get error when deleting fold marker

Problem:    Ml_get error when deleting fold marker.
Solution:   Check that the line number is not below the last line.  Adjust the
            fold when deleting the empty line.  (Christian Brabandt,
            closes vim/vim#4834)
9a4a8c4d59
This commit is contained in:
Jan Edmund Lazo
2019-08-19 21:23:43 -04:00
parent 419c946f03
commit ec9b57cb6e
3 changed files with 36 additions and 11 deletions

View File

@@ -7827,13 +7827,15 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent)
// 'virtualedit' and past the end of the line, we use the 'c' operator in
// do_put(), which requires the visual selection to still be active.
if (!VIsual_active || VIsual_mode == 'V' || regname != '.') {
// Now delete the selected text.
// Now delete the selected text. Avoid messages here.
cap->cmdchar = 'd';
cap->nchar = NUL;
cap->oap->regname = NUL;
msg_silent++;
nv_operator(cap);
do_pending_operator(cap, 0, false);
empty = (curbuf->b_ml.ml_flags & ML_EMPTY);
msg_silent--;
// delete PUT_LINE_BACKWARD;
cap->oap->regname = regname;
@@ -7882,6 +7884,7 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent)
* line that needs to be deleted now. */
if (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL) {
ml_delete(curbuf->b_ml.ml_line_count, true);
deleted_lines(curbuf->b_ml.ml_line_count + 1, 1);
/* If the cursor was in that line, move it to the end of the last
* line. */