mirror of
https://github.com/neovim/neovim.git
synced 2025-12-17 20:05:38 +00:00
vim-patch:8.2.0853: ml_delete() often called with FALSE argument
Problem: ml_delete() often called with FALSE argument.
Solution: Use ml_delete_flags(x, ML_DEL_MESSAGE) when argument is TRUE.
ca70c07b72
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
committed by
zeertzjq
parent
c8912d7329
commit
9b5545103e
@@ -158,12 +158,12 @@ static int read_buffer(bool read_stdin, exarg_T *eap, int flags)
|
|||||||
if (retval == OK) {
|
if (retval == OK) {
|
||||||
// Delete the binary lines.
|
// Delete the binary lines.
|
||||||
while (--line_count >= 0) {
|
while (--line_count >= 0) {
|
||||||
ml_delete(1, false);
|
ml_delete(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Delete the converted lines.
|
// Delete the converted lines.
|
||||||
while (curbuf->b_ml.ml_line_count > line_count) {
|
while (curbuf->b_ml.ml_line_count > line_count) {
|
||||||
ml_delete(line_count, false);
|
ml_delete(line_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Put the cursor on the first line.
|
// Put the cursor on the first line.
|
||||||
@@ -759,7 +759,7 @@ void buf_clear(void)
|
|||||||
linenr_T line_count = curbuf->b_ml.ml_line_count;
|
linenr_T line_count = curbuf->b_ml.ml_line_count;
|
||||||
extmark_free_all(curbuf); // delete any extmarks
|
extmark_free_all(curbuf); // delete any extmarks
|
||||||
while (!(curbuf->b_ml.ml_flags & ML_EMPTY)) {
|
while (!(curbuf->b_ml.ml_flags & ML_EMPTY)) {
|
||||||
ml_delete(1, false);
|
ml_delete(1);
|
||||||
}
|
}
|
||||||
deleted_lines_mark(1, line_count); // prepare for display
|
deleted_lines_mark(1, line_count); // prepare for display
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1981,7 +1981,7 @@ void del_lines(linenr_T nlines, bool undo)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ml_delete(first, true);
|
ml_delete_flags(first, ML_DEL_MESSAGE);
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
// If we delete the last line in the file, stop
|
// If we delete the last line in the file, stop
|
||||||
|
|||||||
@@ -3075,7 +3075,7 @@ static void diffgetput(const int addr_count, const int idx_cur, const int idx_fr
|
|||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
// remember deleting the last line of the buffer
|
// remember deleting the last line of the buffer
|
||||||
buf_empty = curbuf->b_ml.ml_line_count == 1;
|
buf_empty = curbuf->b_ml.ml_line_count == 1;
|
||||||
if (ml_delete(lnum, false) == OK) {
|
if (ml_delete(lnum) == OK) {
|
||||||
added--;
|
added--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3096,7 +3096,7 @@ static void diffgetput(const int addr_count, const int idx_cur, const int idx_fr
|
|||||||
// which results in inaccurate reporting of the byte count of
|
// which results in inaccurate reporting of the byte count of
|
||||||
// previous contents in buffer-update events.
|
// previous contents in buffer-update events.
|
||||||
buf_empty = false;
|
buf_empty = false;
|
||||||
ml_delete(2, false);
|
ml_delete(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
linenr_T new_count = dp->df_count[idx_to] + added;
|
linenr_T new_count = dp->df_count[idx_to] + added;
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ void f_deletebufline(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (linenr_T lnum = first; lnum <= last; lnum++) {
|
for (linenr_T lnum = first; lnum <= last; lnum++) {
|
||||||
ml_delete(first, true);
|
ml_delete_flags(first, ML_DEL_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||||
|
|||||||
@@ -659,7 +659,7 @@ void ex_sort(exarg_T *eap)
|
|||||||
// delete the original lines if appending worked
|
// delete the original lines if appending worked
|
||||||
if (i == count) {
|
if (i == count) {
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
ml_delete(eap->line1, false);
|
ml_delete(eap->line1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
count = 0;
|
count = 0;
|
||||||
@@ -806,7 +806,7 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (l = line1; l <= line2; l++) {
|
for (l = line1; l <= line2; l++) {
|
||||||
ml_delete(line1 + extra, true);
|
ml_delete_flags(line1 + extra, ML_DEL_MESSAGE);
|
||||||
}
|
}
|
||||||
if (!global_busy && num_lines > p_report) {
|
if (!global_busy && num_lines > p_report) {
|
||||||
smsg(0, NGETTEXT("%" PRId64 " line moved",
|
smsg(0, NGETTEXT("%" PRId64 " line moved",
|
||||||
@@ -2867,7 +2867,7 @@ void ex_append(exarg_T *eap)
|
|||||||
lnum++;
|
lnum++;
|
||||||
|
|
||||||
if (empty) {
|
if (empty) {
|
||||||
ml_delete(2, false);
|
ml_delete(2);
|
||||||
empty = false;
|
empty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2917,7 +2917,7 @@ void ex_change(exarg_T *eap)
|
|||||||
if (curbuf->b_ml.ml_flags & ML_EMPTY) { // nothing to delete
|
if (curbuf->b_ml.ml_flags & ML_EMPTY) { // nothing to delete
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ml_delete(eap->line1, false);
|
ml_delete(eap->line1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure the cursor is not beyond the end of the file now
|
// make sure the cursor is not beyond the end of the file now
|
||||||
@@ -4107,7 +4107,7 @@ skip:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (i = 0; i < nmatch_tl; i++) {
|
for (i = 0; i < nmatch_tl; i++) {
|
||||||
ml_delete(lnum, false);
|
ml_delete(lnum);
|
||||||
}
|
}
|
||||||
mark_adjust(lnum, lnum + nmatch_tl - 1, MAXLNUM, -nmatch_tl, kExtmarkNOOP);
|
mark_adjust(lnum, lnum + nmatch_tl - 1, MAXLNUM, -nmatch_tl, kExtmarkNOOP);
|
||||||
if (subflags.do_ask) {
|
if (subflags.do_ask) {
|
||||||
|
|||||||
@@ -5934,7 +5934,7 @@ static void ex_read(exarg_T *eap)
|
|||||||
lnum = 1;
|
lnum = 1;
|
||||||
}
|
}
|
||||||
if (*ml_get(lnum) == NUL && u_savedel(lnum, 1) == OK) {
|
if (*ml_get(lnum) == NUL && u_savedel(lnum, 1) == OK) {
|
||||||
ml_delete(lnum, false);
|
ml_delete(lnum);
|
||||||
if (curwin->w_cursor.lnum > 1
|
if (curwin->w_cursor.lnum > 1
|
||||||
&& curwin->w_cursor.lnum >= lnum) {
|
&& curwin->w_cursor.lnum >= lnum) {
|
||||||
curwin->w_cursor.lnum--;
|
curwin->w_cursor.lnum--;
|
||||||
|
|||||||
@@ -733,7 +733,7 @@ retry:
|
|||||||
}
|
}
|
||||||
// Delete the previously read lines.
|
// Delete the previously read lines.
|
||||||
while (lnum > from) {
|
while (lnum > from) {
|
||||||
ml_delete(lnum--, false);
|
ml_delete(lnum--);
|
||||||
}
|
}
|
||||||
file_rewind = false;
|
file_rewind = false;
|
||||||
if (set_options) {
|
if (set_options) {
|
||||||
@@ -1660,7 +1660,7 @@ failed:
|
|||||||
if (!recoverymode) {
|
if (!recoverymode) {
|
||||||
// need to delete the last line, which comes from the empty buffer
|
// need to delete the last line, which comes from the empty buffer
|
||||||
if (newfile && wasempty && !(curbuf->b_ml.ml_flags & ML_EMPTY)) {
|
if (newfile && wasempty && !(curbuf->b_ml.ml_flags & ML_EMPTY)) {
|
||||||
ml_delete(curbuf->b_ml.ml_line_count, false);
|
ml_delete(curbuf->b_ml.ml_line_count);
|
||||||
linecnt--;
|
linecnt--;
|
||||||
}
|
}
|
||||||
curbuf->deleted_bytes = 0;
|
curbuf->deleted_bytes = 0;
|
||||||
@@ -2836,7 +2836,7 @@ static int move_lines(buf_T *frombuf, buf_T *tobuf)
|
|||||||
if (retval != FAIL) {
|
if (retval != FAIL) {
|
||||||
curbuf = frombuf;
|
curbuf = frombuf;
|
||||||
for (linenr_T lnum = curbuf->b_ml.ml_line_count; lnum > 0; lnum--) {
|
for (linenr_T lnum = curbuf->b_ml.ml_line_count; lnum > 0; lnum--) {
|
||||||
if (ml_delete(lnum, false) == FAIL) {
|
if (ml_delete(lnum) == FAIL) {
|
||||||
// Oops! We could try putting back the saved lines, but that
|
// Oops! We could try putting back the saved lines, but that
|
||||||
// might fail again...
|
// might fail again...
|
||||||
retval = FAIL;
|
retval = FAIL;
|
||||||
@@ -3152,7 +3152,7 @@ void buf_reload(buf_T *buf, int orig_mode, bool reload_options)
|
|||||||
// Put the text back from the save buffer. First
|
// Put the text back from the save buffer. First
|
||||||
// delete any lines that readfile() added.
|
// delete any lines that readfile() added.
|
||||||
while (!buf_is_empty(curbuf)) {
|
while (!buf_is_empty(curbuf)) {
|
||||||
if (ml_delete(buf->b_ml.ml_line_count, false) == FAIL) {
|
if (ml_delete(buf->b_ml.ml_line_count) == FAIL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3809,7 +3809,7 @@ void ins_compl_delete(bool new_leader)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (curwin->w_cursor.lnum > compl_lnum) {
|
while (curwin->w_cursor.lnum > compl_lnum) {
|
||||||
if (ml_delete(curwin->w_cursor.lnum, false) == FAIL) {
|
if (ml_delete(curwin->w_cursor.lnum) == FAIL) {
|
||||||
if (remaining.data) {
|
if (remaining.data) {
|
||||||
xfree(remaining.data);
|
xfree(remaining.data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -961,7 +961,7 @@ void ml_recover(bool checkext)
|
|||||||
// Now that we are sure that the file is going to be recovered, clear the
|
// Now that we are sure that the file is going to be recovered, clear the
|
||||||
// contents of the current buffer.
|
// contents of the current buffer.
|
||||||
while (!(curbuf->b_ml.ml_flags & ML_EMPTY)) {
|
while (!(curbuf->b_ml.ml_flags & ML_EMPTY)) {
|
||||||
ml_delete(1, false);
|
ml_delete(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try reading the original file to obtain the values of 'fileformat',
|
// Try reading the original file to obtain the values of 'fileformat',
|
||||||
@@ -1185,7 +1185,7 @@ void ml_recover(bool checkext)
|
|||||||
// empty buffer. These will now be after the last line in the buffer.
|
// empty buffer. These will now be after the last line in the buffer.
|
||||||
while (curbuf->b_ml.ml_line_count > lnum
|
while (curbuf->b_ml.ml_line_count > lnum
|
||||||
&& !(curbuf->b_ml.ml_flags & ML_EMPTY)) {
|
&& !(curbuf->b_ml.ml_flags & ML_EMPTY)) {
|
||||||
ml_delete(curbuf->b_ml.ml_line_count, false);
|
ml_delete(curbuf->b_ml.ml_line_count);
|
||||||
}
|
}
|
||||||
curbuf->b_flags |= BF_RECOVERED;
|
curbuf->b_flags |= BF_RECOVERED;
|
||||||
check_cursor(curwin);
|
check_cursor(curwin);
|
||||||
@@ -2690,12 +2690,10 @@ static int ml_delete_int(buf_T *buf, linenr_T lnum, int flags)
|
|||||||
/// @note The caller of this function should probably also call
|
/// @note The caller of this function should probably also call
|
||||||
/// deleted_lines() after this.
|
/// deleted_lines() after this.
|
||||||
///
|
///
|
||||||
/// @param message true may give a "No lines in buffer" message.
|
|
||||||
///
|
|
||||||
/// @return FAIL for failure, OK otherwise
|
/// @return FAIL for failure, OK otherwise
|
||||||
int ml_delete(linenr_T lnum, bool message)
|
int ml_delete(linenr_T lnum)
|
||||||
{
|
{
|
||||||
return ml_delete_flags(lnum, message ? ML_DEL_MESSAGE : 0);
|
return ml_delete_flags(lnum, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Like ml_delete() but using flags (see ml_delete_int()).
|
/// Like ml_delete() but using flags (see ml_delete_int()).
|
||||||
|
|||||||
@@ -6598,7 +6598,7 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent)
|
|||||||
// When all lines were selected and deleted do_put() leaves an empty
|
// When all lines were selected and deleted do_put() leaves an empty
|
||||||
// line that needs to be deleted now.
|
// line that needs to be deleted now.
|
||||||
if (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL) {
|
if (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL) {
|
||||||
ml_delete(curbuf->b_ml.ml_line_count, true);
|
ml_delete_flags(curbuf->b_ml.ml_line_count, ML_DEL_MESSAGE);
|
||||||
deleted_lines(curbuf->b_ml.ml_line_count + 1, 1);
|
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
|
// If the cursor was in that line, move it to the end of the last
|
||||||
|
|||||||
@@ -4180,7 +4180,7 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int q
|
|||||||
while ((curbuf->b_ml.ml_flags & ML_EMPTY) == 0) {
|
while ((curbuf->b_ml.ml_flags & ML_EMPTY) == 0) {
|
||||||
// If deletion fails, this loop may run forever, so
|
// If deletion fails, this loop may run forever, so
|
||||||
// signal error and return.
|
// signal error and return.
|
||||||
if (ml_delete(1, false) == FAIL) {
|
if (ml_delete(1) == FAIL) {
|
||||||
internal_error("qf_fill_buffer()");
|
internal_error("qf_fill_buffer()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -4250,7 +4250,7 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int q
|
|||||||
}
|
}
|
||||||
if (old_last == NULL) {
|
if (old_last == NULL) {
|
||||||
// Delete the empty line which is now at the end
|
// Delete the empty line which is now at the end
|
||||||
ml_delete(lnum + 1, false);
|
ml_delete(lnum + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
qfga_clear();
|
qfga_clear();
|
||||||
|
|||||||
@@ -3234,7 +3234,7 @@ void ex_spelldump(exarg_T *eap)
|
|||||||
|
|
||||||
// Delete the empty line that we started with.
|
// Delete the empty line that we started with.
|
||||||
if (curbuf->b_ml.ml_line_count > 1) {
|
if (curbuf->b_ml.ml_line_count > 1) {
|
||||||
ml_delete(curbuf->b_ml.ml_line_count, false);
|
ml_delete(curbuf->b_ml.ml_line_count);
|
||||||
}
|
}
|
||||||
redraw_later(curwin, UPD_NOT_VALID);
|
redraw_later(curwin, UPD_NOT_VALID);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2132,7 +2132,7 @@ static void adjust_scrollback(Terminal *term, buf_T *buf)
|
|||||||
if (scbk < term->sb_current) {
|
if (scbk < term->sb_current) {
|
||||||
size_t diff = term->sb_current - scbk;
|
size_t diff = term->sb_current - scbk;
|
||||||
for (size_t i = 0; i < diff; i++) {
|
for (size_t i = 0; i < diff; i++) {
|
||||||
ml_delete(1, false);
|
ml_delete(1);
|
||||||
term->sb_current--;
|
term->sb_current--;
|
||||||
xfree(term->sb_buffer[term->sb_current]);
|
xfree(term->sb_buffer[term->sb_current]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user