Mercurial > vim
comparison src/ops.c @ 5848:75f222d67cea v7.4.267
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)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 29 Apr 2014 12:15:40 +0200 |
parents | 17903ded5e9a |
children | 88b0571de432 |
comparison
equal
deleted
inserted
replaced
5847:1caf20ceae28 | 5848:75f222d67cea |
---|---|
1977 (void)del_bytes((long)n, !virtual_op, | 1977 (void)del_bytes((long)n, !virtual_op, |
1978 oap->op_type == OP_DELETE && !oap->is_VIsual); | 1978 oap->op_type == OP_DELETE && !oap->is_VIsual); |
1979 curwin->w_cursor = curpos; /* restore curwin->w_cursor */ | 1979 curwin->w_cursor = curpos; /* restore curwin->w_cursor */ |
1980 } | 1980 } |
1981 if (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) | 1981 if (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) |
1982 (void)do_join(2, FALSE, FALSE, FALSE); | 1982 (void)do_join(2, FALSE, FALSE, FALSE, FALSE); |
1983 } | 1983 } |
1984 } | 1984 } |
1985 | 1985 |
1986 msgmore(curbuf->b_ml.ml_line_count - old_lcount); | 1986 msgmore(curbuf->b_ml.ml_line_count - old_lcount); |
1987 | 1987 |
4321 #endif | 4321 #endif |
4322 | 4322 |
4323 /* | 4323 /* |
4324 * Join 'count' lines (minimal 2) at cursor position. | 4324 * Join 'count' lines (minimal 2) at cursor position. |
4325 * When "save_undo" is TRUE save lines for undo first. | 4325 * When "save_undo" is TRUE save lines for undo first. |
4326 * Set "use_formatoptions" to FALSE when e.g. processing | 4326 * Set "use_formatoptions" to FALSE when e.g. processing backspace and comment |
4327 * backspace and comment leaders should not be removed. | 4327 * leaders should not be removed. |
4328 * When setmark is TRUE, sets the '[ and '] mark, else, the caller is expected | |
4329 * to set those marks. | |
4328 * | 4330 * |
4329 * return FAIL for failure, OK otherwise | 4331 * return FAIL for failure, OK otherwise |
4330 */ | 4332 */ |
4331 int | 4333 int |
4332 do_join(count, insert_space, save_undo, use_formatoptions) | 4334 do_join(count, insert_space, save_undo, use_formatoptions, setmark) |
4333 long count; | 4335 long count; |
4334 int insert_space; | 4336 int insert_space; |
4335 int save_undo; | 4337 int save_undo; |
4336 int use_formatoptions UNUSED; | 4338 int use_formatoptions UNUSED; |
4339 int setmark; | |
4337 { | 4340 { |
4338 char_u *curr = NULL; | 4341 char_u *curr = NULL; |
4339 char_u *curr_start = NULL; | 4342 char_u *curr_start = NULL; |
4340 char_u *cend; | 4343 char_u *cend; |
4341 char_u *newp; | 4344 char_u *newp; |
4382 * and setup the array of space strings lengths | 4385 * and setup the array of space strings lengths |
4383 */ | 4386 */ |
4384 for (t = 0; t < count; ++t) | 4387 for (t = 0; t < count; ++t) |
4385 { | 4388 { |
4386 curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t)); | 4389 curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t)); |
4387 if (t == 0) | 4390 if (t == 0 && setmark) |
4388 { | 4391 { |
4389 /* Set the '[ mark. */ | 4392 /* Set the '[ mark. */ |
4390 curwin->w_buffer->b_op_start.lnum = curwin->w_cursor.lnum; | 4393 curwin->w_buffer->b_op_start.lnum = curwin->w_cursor.lnum; |
4391 curwin->w_buffer->b_op_start.col = (colnr_T)STRLEN(curr); | 4394 curwin->w_buffer->b_op_start.col = (colnr_T)STRLEN(curr); |
4392 } | 4395 } |
4504 curr = skipwhite(curr); | 4507 curr = skipwhite(curr); |
4505 currsize = (int)STRLEN(curr); | 4508 currsize = (int)STRLEN(curr); |
4506 } | 4509 } |
4507 ml_replace(curwin->w_cursor.lnum, newp, FALSE); | 4510 ml_replace(curwin->w_cursor.lnum, newp, FALSE); |
4508 | 4511 |
4509 /* Set the '] mark. */ | 4512 if (setmark) |
4510 curwin->w_buffer->b_op_end.lnum = curwin->w_cursor.lnum; | 4513 { |
4511 curwin->w_buffer->b_op_end.col = (colnr_T)STRLEN(newp); | 4514 /* Set the '] mark. */ |
4515 curwin->w_buffer->b_op_end.lnum = curwin->w_cursor.lnum; | |
4516 curwin->w_buffer->b_op_end.col = (colnr_T)STRLEN(newp); | |
4517 } | |
4512 | 4518 |
4513 /* Only report the change in the first line here, del_lines() will report | 4519 /* Only report the change in the first line here, del_lines() will report |
4514 * the deleted line. */ | 4520 * the deleted line. */ |
4515 changed_lines(curwin->w_cursor.lnum, currsize, | 4521 changed_lines(curwin->w_cursor.lnum, currsize, |
4516 curwin->w_cursor.lnum + 1, 0L); | 4522 curwin->w_cursor.lnum + 1, 0L); |
5007 mark_col_adjust(curwin->w_cursor.lnum, | 5013 mark_col_adjust(curwin->w_cursor.lnum, |
5008 (colnr_T)0, 0L, (long)-indent); | 5014 (colnr_T)0, 0L, (long)-indent); |
5009 } | 5015 } |
5010 } | 5016 } |
5011 curwin->w_cursor.lnum--; | 5017 curwin->w_cursor.lnum--; |
5012 if (do_join(2, TRUE, FALSE, FALSE) == FAIL) | 5018 if (do_join(2, TRUE, FALSE, FALSE, FALSE) == FAIL) |
5013 { | 5019 { |
5014 beep_flush(); | 5020 beep_flush(); |
5015 break; | 5021 break; |
5016 } | 5022 } |
5017 first_par_line = FALSE; | 5023 first_par_line = FALSE; |