diff options
author | oni-link <knil.ino@gmail.com> | 2014-05-22 14:37:27 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-05-27 16:51:10 -0400 |
commit | 753401ab4cea8fc81731403fe587558e36e7388f (patch) | |
tree | bcf0f4d7be21ac0055aa1c091e96caca44046d6e /src/nvim/ops.c | |
parent | 1b43e5c47e3887696d53573fba7fce6221888794 (diff) | |
download | rneovim-753401ab4cea8fc81731403fe587558e36e7388f.tar.gz rneovim-753401ab4cea8fc81731403fe587558e36e7388f.tar.bz2 rneovim-753401ab4cea8fc81731403fe587558e36e7388f.zip |
vim-patch:7.4.267
Problem: The '[ mark is in the wrong position after "gq". (Ingo Karkat)
Solution: Add the setmark argument to do_join(). (Christian Brabandt)
https://code.google.com/p/vim/source/detail?r=75f222d67cea335efbe0274de6340dba174c1e7e
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; } |