1
0
forked from aniani/vim

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)
This commit is contained in:
Bram Moolenaar 2014-04-29 12:15:40 +02:00
parent 33e87789a7
commit d69bd9af3c
16 changed files with 65 additions and 17 deletions

View File

@ -1880,6 +1880,7 @@ unittest unittests: $(UNITTEST_TARGETS)
# Run individual test, assuming that Vim was already compiled. # Run individual test, assuming that Vim was already compiled.
test1 test2 test3 test4 test5 test6 test7 test8 test9 \ test1 test2 test3 test4 test5 test6 test7 test8 test9 \
test_autoformat_join \
test_eval \ test_eval \
test_options \ test_options \
test10 test11 test12 test13 test14 test15 test16 test17 test18 test19 \ test10 test11 test12 test13 test14 test15 test16 test17 test18 test19 \

View File

@ -8685,7 +8685,7 @@ ins_del()
{ {
temp = curwin->w_cursor.col; temp = curwin->w_cursor.col;
if (!can_bs(BS_EOL) /* only if "eol" included */ 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(); vim_beep();
else else
curwin->w_cursor.col = temp; curwin->w_cursor.col = temp;
@ -8866,7 +8866,7 @@ ins_bs(c, mode, inserted_space_p)
ptr[len - 1] = NUL; 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) if (temp == NUL && gchar_cursor() != NUL)
inc_cursor(); inc_cursor();
} }

View File

@ -4444,7 +4444,7 @@ do_sub(eap)
else if (*cmd == 'p') else if (*cmd == 'p')
eap->flags = EXFLAG_PRINT; 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; sub_nlines = sub_nsubs = eap->line2 - eap->line1 + 1;
(void)do_sub_msg(FALSE); (void)do_sub_msg(FALSE);
ex_may_print(eap); ex_may_print(eap);

View File

@ -8717,7 +8717,7 @@ ex_join(eap)
} }
++eap->line2; ++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); beginline(BL_WHITE | BL_FIX);
ex_may_print(eap); ex_may_print(eap);
} }

View File

@ -812,7 +812,7 @@ getcount:
if (text_locked() && (nv_cmds[idx].cmd_flags & NV_NCW)) 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); clearopbeep(oap);
text_locked_msg(); text_locked_msg();
goto normal_end; goto normal_end;
@ -1905,7 +1905,7 @@ do_pending_operator(cap, old_col, gui_yank)
else else
{ {
(void)do_join(oap->line_count, oap->op_type == OP_JOIN, (void)do_join(oap->line_count, oap->op_type == OP_JOIN,
TRUE, TRUE); TRUE, TRUE, TRUE);
auto_format(FALSE, TRUE); auto_format(FALSE, TRUE);
} }
break; break;
@ -9236,7 +9236,7 @@ nv_join(cap)
{ {
prep_redo(cap->oap->regname, cap->count0, prep_redo(cap->oap->regname, cap->count0,
NUL, cap->cmdchar, NUL, NUL, cap->nchar); 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);
} }
} }
} }

View File

@ -1979,7 +1979,7 @@ op_delete(oap)
curwin->w_cursor = curpos; /* restore curwin->w_cursor */ curwin->w_cursor = curpos; /* restore curwin->w_cursor */
} }
if (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) 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_space, is_comment)
/* /*
* Join 'count' lines (minimal 2) at cursor position. * Join 'count' lines (minimal 2) at cursor position.
* When "save_undo" is TRUE save lines for undo first. * When "save_undo" is TRUE save lines for undo first.
* Set "use_formatoptions" to FALSE when e.g. processing * Set "use_formatoptions" to FALSE when e.g. processing backspace and comment
* backspace and comment leaders should not be removed. * 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 * return FAIL for failure, OK otherwise
*/ */
int int
do_join(count, insert_space, save_undo, use_formatoptions) do_join(count, insert_space, save_undo, use_formatoptions, setmark)
long count; long count;
int insert_space; int insert_space;
int save_undo; int save_undo;
int use_formatoptions UNUSED; int use_formatoptions UNUSED;
int setmark;
{ {
char_u *curr = NULL; char_u *curr = NULL;
char_u *curr_start = NULL; char_u *curr_start = NULL;
@ -4384,7 +4387,7 @@ do_join(count, insert_space, save_undo, use_formatoptions)
for (t = 0; t < count; ++t) for (t = 0; 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) if (t == 0 && setmark)
{ {
/* Set the '[ mark. */ /* Set the '[ mark. */
curwin->w_buffer->b_op_start.lnum = curwin->w_cursor.lnum; curwin->w_buffer->b_op_start.lnum = curwin->w_cursor.lnum;
@ -4506,9 +4509,12 @@ do_join(count, insert_space, save_undo, use_formatoptions)
} }
ml_replace(curwin->w_cursor.lnum, newp, FALSE); ml_replace(curwin->w_cursor.lnum, newp, FALSE);
/* Set the '] mark. */ if (setmark)
curwin->w_buffer->b_op_end.lnum = curwin->w_cursor.lnum; {
curwin->w_buffer->b_op_end.col = (colnr_T)STRLEN(newp); /* 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 /* Only report the change in the first line here, del_lines() will report
* the deleted line. */ * the deleted line. */
@ -5009,7 +5015,7 @@ format_lines(line_count, avoid_fex)
} }
} }
curwin->w_cursor.lnum--; curwin->w_cursor.lnum--;
if (do_join(2, TRUE, FALSE, FALSE) == FAIL) if (do_join(2, TRUE, FALSE, FALSE, FALSE) == FAIL)
{ {
beep_flush(); beep_flush();
break; break;

View File

@ -37,7 +37,7 @@ void adjust_cursor_eol __ARGS((void));
int preprocs_left __ARGS((void)); int preprocs_left __ARGS((void));
int get_register_name __ARGS((int num)); int get_register_name __ARGS((int num));
void ex_display __ARGS((exarg_T *eap)); 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_format __ARGS((oparg_T *oap, int keep_cursor));
void op_formatexpr __ARGS((oparg_T *oap)); void op_formatexpr __ARGS((oparg_T *oap));
int fex_format __ARGS((linenr_T lnum, long count, int c)); int fex_format __ARGS((linenr_T lnum, long count, int c));

View File

@ -36,6 +36,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
test94.out test95.out test96.out test97.out test98.out \ test94.out test95.out test96.out test97.out test98.out \
test99.out test100.out test101.out test102.out test103.out \ test99.out test100.out test101.out test102.out test103.out \
test104.out test105.out test106.out \ test104.out test105.out test106.out \
test_autoformat_join.out \
test_eval.out \ test_eval.out \
test_options.out test_options.out
@ -160,5 +161,6 @@ test103.out: test103.in
test104.out: test104.in test104.out: test104.in
test105.out: test105.in test105.out: test105.in
test106.out: test106.in test106.out: test106.in
test_autoformat_join.out: test_autoformat_join.in
test_eval.out: test_eval.in test_eval.out: test_eval.in
test_options.out: test_options.in test_options.out: test_options.in

View File

@ -35,6 +35,7 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
test94.out test95.out test96.out test98.out test99.out \ test94.out test95.out test96.out test98.out test99.out \
test100.out test101.out test102.out test103.out test104.out \ test100.out test101.out test102.out test103.out test104.out \
test105.out test106.out \ test105.out test106.out \
test_autoformat_join.out \
test_eval.out \ test_eval.out \
test_options.out test_options.out

View File

@ -55,6 +55,7 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
test94.out test95.out test96.out test98.out test99.out \ test94.out test95.out test96.out test98.out test99.out \
test100.out test101.out test102.out test103.out test104.out \ test100.out test101.out test102.out test103.out test104.out \
test105.out test106.out \ test105.out test106.out \
test_autoformat_join.out \
test_eval.out \ test_eval.out \
test_options.out test_options.out

View File

@ -37,6 +37,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
test94.out test95.out test96.out test98.out test99.out \ test94.out test95.out test96.out test98.out test99.out \
test100.out test101.out test102.out test103.out test104.out \ test100.out test101.out test102.out test103.out test104.out \
test105.out test106.out \ test105.out test106.out \
test_autoformat_join.out \
test_eval.out \ test_eval.out \
test_options.out test_options.out

View File

@ -96,6 +96,7 @@ SCRIPT = test1.out test2.out test3.out test4.out test5.out \
test95.out test96.out test98.out test99.out \ test95.out test96.out test98.out test99.out \
test100.out test101.out test103.out test104.out \ test100.out test101.out test103.out test104.out \
test105.out test106.out \ test105.out test106.out \
test_autoformat_join.out \
test_eval.out \ test_eval.out \
test_options.out test_options.out

View File

@ -33,6 +33,8 @@ SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
test94.out test95.out test96.out test97.out test98.out \ test94.out test95.out test96.out test97.out test98.out \
test99.out test100.out test101.out test102.out test103.out \ test99.out test100.out test101.out test102.out test103.out \
test104.out test105.out test106.out \ test104.out test105.out test106.out \
test_autoformat_join.out \
test_eval.out \
test_options.out test_options.out
SCRIPTS_GUI = test16.out SCRIPTS_GUI = test16.out

View File

@ -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:

View File

@ -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]'

View File

@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
267,
/**/ /**/
266, 266,
/**/ /**/