buffer_updates: prefer using ml_add_deleted_len_buf

This commit is contained in:
Thomas Vigouroux
2020-07-20 23:28:05 +02:00
parent 2c34780c32
commit be057197d3

View File

@@ -2447,14 +2447,14 @@ int ml_replace_buf(buf_T *buf, linenr_T lnum, char_u *line, bool copy)
if (buf->b_ml.ml_line_lnum != lnum) { // other line buffered
ml_flush_line(buf); // flush it
} else if (buf->b_ml.ml_flags & ML_LINE_DIRTY) { // same line allocated
ml_add_deleted_len(buf->b_ml.ml_line_ptr, -1);
ml_add_deleted_len_buf(buf, buf->b_ml.ml_line_ptr, -1);
readlen = false; // already added the length
xfree(buf->b_ml.ml_line_ptr); // free it
}
if (readlen && kv_size(buf->update_callbacks)) {
ml_add_deleted_len(ml_get_buf(buf, lnum, false), -1);
ml_add_deleted_len_buf(buf, ml_get_buf(buf, lnum, false), -1);
}
buf->b_ml.ml_line_ptr = line;
@@ -2541,7 +2541,7 @@ static int ml_delete_int(buf_T *buf, linenr_T lnum, bool message)
// Line should always have an NL char internally (represented as NUL),
// even if 'noeol' is set.
assert(line_size >= 1);
ml_add_deleted_len((char_u *)dp + line_start, line_size-1);
ml_add_deleted_len_buf(buf, (char_u *)dp + line_start, line_size-1);
/*
* special case: If there is only one line in the data block it becomes empty.