mirror of
https://github.com/neovim/neovim.git
synced 2025-10-04 17:06:30 +00:00
remove some asserts and lint
This commit is contained in:
@@ -1795,9 +1795,9 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
|
|||||||
if (oap->line_count < 2)
|
if (oap->line_count < 2)
|
||||||
oap->line_count = 2;
|
oap->line_count = 2;
|
||||||
if (curwin->w_cursor.lnum + oap->line_count - 1 >
|
if (curwin->w_cursor.lnum + oap->line_count - 1 >
|
||||||
curbuf->b_ml.ml_line_count)
|
curbuf->b_ml.ml_line_count) {
|
||||||
beep_flush();
|
beep_flush();
|
||||||
else {
|
} else {
|
||||||
do_join((size_t)oap->line_count, oap->op_type == OP_JOIN,
|
do_join((size_t)oap->line_count, oap->op_type == OP_JOIN,
|
||||||
true, true, true);
|
true, true, true);
|
||||||
auto_format(false, true);
|
auto_format(false, true);
|
||||||
|
@@ -1007,10 +1007,9 @@ do_execreg (
|
|||||||
put_reedit_in_typebuf(silent);
|
put_reedit_in_typebuf(silent);
|
||||||
char_u *escaped;
|
char_u *escaped;
|
||||||
for (size_t i = reg->y_size; i-- > 0;) { // from y_size - 1 to 0 included
|
for (size_t i = reg->y_size; i-- > 0;) { // from y_size - 1 to 0 included
|
||||||
|
|
||||||
// insert NL between lines and after last line if type is kMTLineWise
|
// insert NL between lines and after last line if type is kMTLineWise
|
||||||
if (reg->y_type == kMTLineWise || i < reg->y_size - 1 || addcr) {
|
if (reg->y_type == kMTLineWise || i < reg->y_size - 1 || addcr) {
|
||||||
if (ins_typebuf((char_u *)"\n", remap, 0, TRUE, silent) == FAIL) {
|
if (ins_typebuf((char_u *)"\n", remap, 0, true, silent) == FAIL) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2318,15 +2317,14 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
|
|||||||
|
|
||||||
yankreg_T *curr = reg; // copy of current register
|
yankreg_T *curr = reg; // copy of current register
|
||||||
// append to existing contents
|
// append to existing contents
|
||||||
if (append && reg->y_array != NULL)
|
if (append && reg->y_array != NULL) {
|
||||||
reg = &newreg;
|
reg = &newreg;
|
||||||
else
|
} else {
|
||||||
free_register(reg); /* free previously yanked lines */
|
free_register(reg); // free previously yanked lines
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
// If the cursor was in column 1 before and after the movement, and the
|
||||||
* If the cursor was in column 1 before and after the movement, and the
|
// operator is not inclusive, the yank is always linewise.
|
||||||
* operator is not inclusive, the yank is always linewise.
|
|
||||||
*/
|
|
||||||
if (oap->motion_type == kMTCharWise
|
if (oap->motion_type == kMTCharWise
|
||||||
&& oap->start.col == 0
|
&& oap->start.col == 0
|
||||||
&& !oap->inclusive
|
&& !oap->inclusive
|
||||||
@@ -2506,7 +2504,6 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
|
|||||||
|
|
||||||
static void yank_copy_line(yankreg_T *reg, struct block_def *bd, size_t y_idx)
|
static void yank_copy_line(yankreg_T *reg, struct block_def *bd, size_t y_idx)
|
||||||
{
|
{
|
||||||
assert(bd->startspaces + bd->endspaces + bd->textlen >= 0);
|
|
||||||
char_u *pnew = xmallocz((size_t)(bd->startspaces + bd->endspaces
|
char_u *pnew = xmallocz((size_t)(bd->startspaces + bd->endspaces
|
||||||
+ bd->textlen));
|
+ bd->textlen));
|
||||||
reg->y_array[y_idx] = pnew;
|
reg->y_array[y_idx] = pnew;
|
||||||
@@ -2756,10 +2753,12 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
|
|
||||||
if (y_type == kMTBlockWise) {
|
if (y_type == kMTBlockWise) {
|
||||||
lnum = curwin->w_cursor.lnum + (linenr_T)y_size + 1;
|
lnum = curwin->w_cursor.lnum + (linenr_T)y_size + 1;
|
||||||
if (lnum > curbuf->b_ml.ml_line_count)
|
if (lnum > curbuf->b_ml.ml_line_count) {
|
||||||
lnum = curbuf->b_ml.ml_line_count + 1;
|
lnum = curbuf->b_ml.ml_line_count + 1;
|
||||||
if (u_save(curwin->w_cursor.lnum - 1, lnum) == FAIL)
|
}
|
||||||
|
if (u_save(curwin->w_cursor.lnum - 1, lnum) == FAIL) {
|
||||||
goto end;
|
goto end;
|
||||||
|
}
|
||||||
} else if (y_type == kMTLineWise) {
|
} else if (y_type == kMTLineWise) {
|
||||||
lnum = curwin->w_cursor.lnum;
|
lnum = curwin->w_cursor.lnum;
|
||||||
/* Correct line number for closed fold. Don't move the cursor yet,
|
/* Correct line number for closed fold. Don't move the cursor yet,
|
||||||
@@ -2920,11 +2919,10 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
/* may insert some spaces after the new text */
|
/* may insert some spaces after the new text */
|
||||||
memset(ptr, ' ', (size_t)bd.endspaces);
|
memset(ptr, ' ', (size_t)bd.endspaces);
|
||||||
ptr += bd.endspaces;
|
ptr += bd.endspaces;
|
||||||
/* move the text after the cursor to the end of the line. */
|
// move the text after the cursor to the end of the line.
|
||||||
assert(oldlen <= INT_MAX);
|
|
||||||
memmove(ptr, oldp + bd.textcol + delcount,
|
memmove(ptr, oldp + bd.textcol + delcount,
|
||||||
(size_t)((int)oldlen - bd.textcol - delcount + 1));
|
(size_t)((int)oldlen - bd.textcol - delcount + 1));
|
||||||
ml_replace(curwin->w_cursor.lnum, newp, FALSE);
|
ml_replace(curwin->w_cursor.lnum, newp, false);
|
||||||
|
|
||||||
++curwin->w_cursor.lnum;
|
++curwin->w_cursor.lnum;
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
@@ -3458,19 +3456,17 @@ int do_join(size_t count,
|
|||||||
curwin->w_cursor.lnum + (linenr_T)count) == FAIL) {
|
curwin->w_cursor.lnum + (linenr_T)count) == FAIL) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
/* Allocate an array to store the number of spaces inserted before each
|
// Allocate an array to store the number of spaces inserted before each
|
||||||
* line. We will use it to pre-compute the length of the new line and the
|
// line. We will use it to pre-compute the length of the new line and the
|
||||||
* proper placement of each original line in the new one. */
|
// proper placement of each original line in the new one.
|
||||||
spaces = xcalloc(count, 1);
|
spaces = xcalloc(count, 1);
|
||||||
if (remove_comments) {
|
if (remove_comments) {
|
||||||
comments = xcalloc(count, sizeof(*comments));
|
comments = xcalloc(count, sizeof(*comments));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Don't move anything, just compute the final line length
|
||||||
* Don't move anything, just compute the final line length
|
// and setup the array of space strings lengths
|
||||||
* and setup the array of space strings lengths
|
for (t = 0; t < (linenr_T)count; t++) {
|
||||||
*/
|
|
||||||
for (t = 0; t < (linenr_T)count; ++t) {
|
|
||||||
curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t));
|
curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t));
|
||||||
if (t == 0 && setmark) {
|
if (t == 0 && setmark) {
|
||||||
// Set the '[ mark.
|
// Set the '[ mark.
|
||||||
@@ -4903,7 +4899,8 @@ void write_reg_contents_lst(int name, char_u **strings, int maxlen,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
str_to_reg(reg, yank_type, (char_u *)strings, STRLEN((char_u *)strings), block_len, true);
|
str_to_reg(reg, yank_type, (char_u *)strings, STRLEN((char_u *)strings),
|
||||||
|
block_len, true);
|
||||||
finish_write_reg(name, reg, old_y_previous);
|
finish_write_reg(name, reg, old_y_previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5511,7 +5508,6 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet)
|
|||||||
reg->y_type = kMTUnknown;
|
reg->y_type = kMTUnknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(lines->lv_len >= 0);
|
|
||||||
reg->y_array = xcalloc((size_t)lines->lv_len, sizeof(uint8_t *));
|
reg->y_array = xcalloc((size_t)lines->lv_len, sizeof(uint8_t *));
|
||||||
reg->y_size = (size_t)lines->lv_len;
|
reg->y_size = (size_t)lines->lv_len;
|
||||||
reg->additional_data = NULL;
|
reg->additional_data = NULL;
|
||||||
|
Reference in New Issue
Block a user