diff options
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r-- | src/nvim/ops.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index dccc3e6324..05ca402d39 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -1623,8 +1623,9 @@ int op_delete(oparg_T *oap) ); curwin->w_cursor = curpos; /* restore curwin->w_cursor */ } - if (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) - (void)do_join(2, FALSE, FALSE, FALSE); + if (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) { + do_join(2, FALSE, FALSE, FALSE, false); + } } } @@ -3381,15 +3382,19 @@ static char_u *skip_comment(char_u *line, int process, int include_space, int *i return line; } -/* - * Join 'count' lines (minimal 2) at cursor position. - * When "save_undo" is TRUE save lines for undo first. - * Set "use_formatoptions" to FALSE when e.g. processing - * backspace and comment leaders should not be removed. - * - * return FAIL for failure, OK otherwise - */ -int do_join(long count, int insert_space, int save_undo, int use_formatoptions) +// Join 'count' lines (minimal 2) at cursor position. +// When "save_undo" is TRUE save lines for undo first. +// Set "use_formatoptions" to FALSE when e.g. processing backspace and comment +// leaders should not be removed. +// When setmark is true, sets the '[ and '] mark, else, the caller is expected +// to set those marks. +// +// return FAIL for failure, OK otherwise +int do_join(long count, + int insert_space, + int save_undo, + int use_formatoptions, + bool setmark) { char_u *curr = NULL; char_u *curr_start = NULL; @@ -3427,7 +3432,7 @@ int do_join(long count, int insert_space, int save_undo, int use_formatoptions) */ for (t = 0; t < count; ++t) { curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t)); - if (t == 0) { + if (t == 0 && setmark) { // Set the '[ mark. curwin->w_buffer->b_op_start.lnum = curwin->w_cursor.lnum; curwin->w_buffer->b_op_start.col = (colnr_T)STRLEN(curr); @@ -3527,9 +3532,11 @@ int do_join(long count, int insert_space, int save_undo, int use_formatoptions) } ml_replace(curwin->w_cursor.lnum, newp, FALSE); - // Set the '] mark. - curwin->w_buffer->b_op_end.lnum = curwin->w_cursor.lnum; - curwin->w_buffer->b_op_end.col = (colnr_T)STRLEN(newp); + if (setmark) { + // Set the '] mark. + curwin->w_buffer->b_op_end.lnum = curwin->w_cursor.lnum; + curwin->w_buffer->b_op_end.col = (colnr_T)STRLEN(newp); + } /* Only report the change in the first line here, del_lines() will report * the deleted line. */ @@ -3953,7 +3960,7 @@ format_lines ( } } curwin->w_cursor.lnum--; - if (do_join(2, TRUE, FALSE, FALSE) == FAIL) { + if (do_join(2, TRUE, FALSE, FALSE, false) == FAIL) { beep_flush(); break; } |