# HG changeset patch # User Bram Moolenaar # Date 1398766540 -7200 # Node ID 75f222d67cea335efbe0274de6340dba174c1e7e # Parent 1caf20ceae289655aebf66306b8953eb5c71810f updated for version 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) diff --git a/src/Makefile b/src/Makefile --- a/src/Makefile +++ b/src/Makefile @@ -1880,6 +1880,7 @@ unittest unittests: $(UNITTEST_TARGETS) # Run individual test, assuming that Vim was already compiled. test1 test2 test3 test4 test5 test6 test7 test8 test9 \ + test_autoformat_join \ test_eval \ test_options \ test10 test11 test12 test13 test14 test15 test16 test17 test18 test19 \ diff --git a/src/edit.c b/src/edit.c --- a/src/edit.c +++ b/src/edit.c @@ -8685,7 +8685,7 @@ ins_del() { temp = curwin->w_cursor.col; if (!can_bs(BS_EOL) /* only if "eol" included */ - || do_join(2, FALSE, TRUE, FALSE) == FAIL) + || do_join(2, FALSE, TRUE, FALSE, FALSE) == FAIL) vim_beep(); else curwin->w_cursor.col = temp; @@ -8866,7 +8866,7 @@ ins_bs(c, mode, inserted_space_p) ptr[len - 1] = NUL; } - (void)do_join(2, FALSE, FALSE, FALSE); + (void)do_join(2, FALSE, FALSE, FALSE, FALSE); if (temp == NUL && gchar_cursor() != NUL) inc_cursor(); } diff --git a/src/ex_cmds.c b/src/ex_cmds.c --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -4444,7 +4444,7 @@ do_sub(eap) else if (*cmd == 'p') eap->flags = EXFLAG_PRINT; - (void)do_join(eap->line2 - eap->line1 + 1, FALSE, TRUE, FALSE); + (void)do_join(eap->line2 - eap->line1 + 1, FALSE, TRUE, FALSE, TRUE); sub_nlines = sub_nsubs = eap->line2 - eap->line1 + 1; (void)do_sub_msg(FALSE); ex_may_print(eap); diff --git a/src/ex_docmd.c b/src/ex_docmd.c --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -8717,7 +8717,7 @@ ex_join(eap) } ++eap->line2; } - (void)do_join(eap->line2 - eap->line1 + 1, !eap->forceit, TRUE, TRUE); + (void)do_join(eap->line2 - eap->line1 + 1, !eap->forceit, TRUE, TRUE, TRUE); beginline(BL_WHITE | BL_FIX); ex_may_print(eap); } diff --git a/src/normal.c b/src/normal.c --- a/src/normal.c +++ b/src/normal.c @@ -812,7 +812,7 @@ getcount: if (text_locked() && (nv_cmds[idx].cmd_flags & NV_NCW)) { - /* This command is not allowed while editing a ccmdline: beep. */ + /* This command is not allowed while editing a cmdline: beep. */ clearopbeep(oap); text_locked_msg(); goto normal_end; @@ -1905,7 +1905,7 @@ do_pending_operator(cap, old_col, gui_ya else { (void)do_join(oap->line_count, oap->op_type == OP_JOIN, - TRUE, TRUE); + TRUE, TRUE, TRUE); auto_format(FALSE, TRUE); } break; @@ -9236,7 +9236,7 @@ nv_join(cap) { prep_redo(cap->oap->regname, cap->count0, NUL, cap->cmdchar, NUL, NUL, cap->nchar); - (void)do_join(cap->count0, cap->nchar == NUL, TRUE, TRUE); + (void)do_join(cap->count0, cap->nchar == NUL, TRUE, TRUE, TRUE); } } } diff --git a/src/ops.c b/src/ops.c --- a/src/ops.c +++ b/src/ops.c @@ -1979,7 +1979,7 @@ op_delete(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); + (void)do_join(2, FALSE, FALSE, FALSE, FALSE); } } @@ -4323,17 +4323,20 @@ skip_comment(line, process, include_spac /* * 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. + * 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(count, insert_space, save_undo, use_formatoptions) +do_join(count, insert_space, save_undo, use_formatoptions, setmark) long count; int insert_space; int save_undo; int use_formatoptions UNUSED; + int setmark; { char_u *curr = NULL; char_u *curr_start = NULL; @@ -4384,7 +4387,7 @@ do_join(count, insert_space, save_undo, 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; @@ -4506,9 +4509,12 @@ do_join(count, insert_space, save_undo, } 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. */ @@ -5009,7 +5015,7 @@ format_lines(line_count, avoid_fex) } } curwin->w_cursor.lnum--; - if (do_join(2, TRUE, FALSE, FALSE) == FAIL) + if (do_join(2, TRUE, FALSE, FALSE, FALSE) == FAIL) { beep_flush(); break; diff --git a/src/proto/ops.pro b/src/proto/ops.pro --- a/src/proto/ops.pro +++ b/src/proto/ops.pro @@ -37,7 +37,7 @@ void adjust_cursor_eol __ARGS((void)); int preprocs_left __ARGS((void)); int get_register_name __ARGS((int num)); void ex_display __ARGS((exarg_T *eap)); -int do_join __ARGS((long count, int insert_space, int save_undo, int use_formatoptions)); +int do_join __ARGS((long count, int insert_space, int save_undo, int use_formatoptions, int setmark)); void op_format __ARGS((oparg_T *oap, int keep_cursor)); void op_formatexpr __ARGS((oparg_T *oap)); int fex_format __ARGS((linenr_T lnum, long count, int c)); diff --git a/src/testdir/Make_amiga.mak b/src/testdir/Make_amiga.mak --- a/src/testdir/Make_amiga.mak +++ b/src/testdir/Make_amiga.mak @@ -36,6 +36,7 @@ SCRIPTS = test1.out test3.out test4.out test94.out test95.out test96.out test97.out test98.out \ test99.out test100.out test101.out test102.out test103.out \ test104.out test105.out test106.out \ + test_autoformat_join.out \ test_eval.out \ test_options.out @@ -160,5 +161,6 @@ test103.out: test103.in test104.out: test104.in test105.out: test105.in test106.out: test106.in +test_autoformat_join.out: test_autoformat_join.in test_eval.out: test_eval.in test_options.out: test_options.in diff --git a/src/testdir/Make_dos.mak b/src/testdir/Make_dos.mak --- a/src/testdir/Make_dos.mak +++ b/src/testdir/Make_dos.mak @@ -35,6 +35,7 @@ SCRIPTS = test3.out test4.out test5.out test94.out test95.out test96.out test98.out test99.out \ test100.out test101.out test102.out test103.out test104.out \ test105.out test106.out \ + test_autoformat_join.out \ test_eval.out \ test_options.out diff --git a/src/testdir/Make_ming.mak b/src/testdir/Make_ming.mak --- a/src/testdir/Make_ming.mak +++ b/src/testdir/Make_ming.mak @@ -55,6 +55,7 @@ SCRIPTS = test3.out test4.out test5.out test94.out test95.out test96.out test98.out test99.out \ test100.out test101.out test102.out test103.out test104.out \ test105.out test106.out \ + test_autoformat_join.out \ test_eval.out \ test_options.out diff --git a/src/testdir/Make_os2.mak b/src/testdir/Make_os2.mak --- a/src/testdir/Make_os2.mak +++ b/src/testdir/Make_os2.mak @@ -37,6 +37,7 @@ SCRIPTS = test1.out test3.out test4.out test94.out test95.out test96.out test98.out test99.out \ test100.out test101.out test102.out test103.out test104.out \ test105.out test106.out \ + test_autoformat_join.out \ test_eval.out \ test_options.out diff --git a/src/testdir/Make_vms.mms b/src/testdir/Make_vms.mms --- a/src/testdir/Make_vms.mms +++ b/src/testdir/Make_vms.mms @@ -96,6 +96,7 @@ SCRIPT = test1.out test2.out test3.out test95.out test96.out test98.out test99.out \ test100.out test101.out test103.out test104.out \ test105.out test106.out \ + test_autoformat_join.out \ test_eval.out \ test_options.out diff --git a/src/testdir/Makefile b/src/testdir/Makefile --- a/src/testdir/Makefile +++ b/src/testdir/Makefile @@ -33,6 +33,8 @@ SCRIPTS = test1.out test2.out test3.out test94.out test95.out test96.out test97.out test98.out \ test99.out test100.out test101.out test102.out test103.out \ test104.out test105.out test106.out \ + test_autoformat_join.out \ + test_eval.out \ test_options.out SCRIPTS_GUI = test16.out diff --git a/src/testdir/test_autoformat_join.in b/src/testdir/test_autoformat_join.in new file mode 100644 --- /dev/null +++ b/src/testdir/test_autoformat_join.in @@ -0,0 +1,23 @@ +Tests for setting the '[,'] marks when joining lines. + +STARTTEST +:so small.vim +:/^\t\t/ +0gqj +:let a=string(getpos("'[")).'/'.string(getpos("']")) +:/^This line/;'}-join +:let b=string(getpos("'[")).'/'.string(getpos("']")) +:$put ='First test: Start/End '.string(a) +:$put ='Second test: Start/End '.string(b) +:/^\t\t/,$wq! test.out +ENDTEST + + + O sodales, ludite, vos qui +attamen consulite per voster honur. Tua pulchra facies me fay planszer milies + +This line. +Should be joined with the next line +and with this line + +Results: diff --git a/src/testdir/test_autoformat_join.ok b/src/testdir/test_autoformat_join.ok new file mode 100644 --- /dev/null +++ b/src/testdir/test_autoformat_join.ok @@ -0,0 +1,8 @@ + O sodales, ludite, vos qui attamen consulite per voster honur. +Tua pulchra facies me fay planszer milies + +This line. Should be joined with the next line and with this line + +Results: +First test: Start/End '[0, 16, 1, 0]/[0, 17, 1, 0]' +Second test: Start/End '[0, 19, 11, 0]/[0, 19, 67, 0]' diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -735,6 +735,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 267, +/**/ 266, /**/ 265,