diff options
author | Bram Moolenaar <bram@vim.org> | 2010-10-09 17:23:31 +0200 |
---|---|---|
committer | Bram Moolenaar <bram@vim.org> | 2010-10-09 17:23:31 +0200 |
commit | 3b523026aae5928b91121d2c7ff1aaaadb289a27 (patch) | |
tree | 6a8ece3eaaa14bc8f1e2ce396d37bcd5fc27d9a6 | |
parent | 953daca4f67fd21d389b4c5a1339828d01383aa4 (diff) | |
download | vim-3b523026aae5928b91121d2c7ff1aaaadb289a27.tar.gz |
Problem: Cursor position wrong when joining multiple lines and
'formatoptions' contains "a". (Moshe Kamensky)
Solution: Adjust cursor position for skipped indent. (Carlo Teubner)
-rw-r--r-- | src/ops.c | 9 | ||||
-rw-r--r-- | src/testdir/test68.in | 11 | ||||
-rw-r--r-- | src/testdir/test68.ok | 3 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 21 insertions, 4 deletions
@@ -4153,9 +4153,10 @@ do_join(count, insert_space, save_undo) int save_undo; { char_u *curr = NULL; + char_u *curr_start = NULL; char_u *cend; char_u *newp; - char_u *spaces; /* number of spaces inserte before a line */ + char_u *spaces; /* number of spaces inserted before a line */ int endcurr1 = NUL; int endcurr2 = NUL; int currsize = 0; /* size of the current line */ @@ -4181,7 +4182,7 @@ do_join(count, insert_space, save_undo) */ for (t = 0; t < count; ++t) { - curr = ml_get((linenr_T)(curwin->w_cursor.lnum + t)); + curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t)); if (insert_space && t > 0) { curr = skipwhite(curr); @@ -4265,10 +4266,10 @@ do_join(count, insert_space, save_undo) copy_spaces(cend, (size_t)(spaces[t])); } mark_col_adjust(curwin->w_cursor.lnum + t, (colnr_T)0, (linenr_T)-t, - (long)(cend - newp + spaces[t])); + (long)(cend - newp + spaces[t] - (curr - curr_start))); if (t == 0) break; - curr = ml_get((linenr_T)(curwin->w_cursor.lnum + t - 1)); + curr = curr_start = ml_get((linenr_T)(curwin->w_cursor.lnum + t - 1)); if (insert_space && t > 1) curr = skipwhite(curr); currsize = (int)STRLEN(curr); diff --git a/src/testdir/test68.in b/src/testdir/test68.in index 94104c07..8d0c501e 100644 --- a/src/testdir/test68.in +++ b/src/testdir/test68.in @@ -51,6 +51,17 @@ a b } STARTTEST +/^{/+2 +:set tw& fo=a +I^^ +ENDTEST + +{ + 1aa + 2bb +} + +STARTTEST :g/^STARTTEST/.,/^ENDTEST/d :1;/^Results/,$wq! test.out ENDTEST diff --git a/src/testdir/test68.ok b/src/testdir/test68.ok index 85f35cfc..aebe3643 100644 --- a/src/testdir/test68.ok +++ b/src/testdir/test68.ok @@ -33,3 +33,6 @@ a b #a b } + +{ 1aa ^^2bb } + diff --git a/src/version.c b/src/version.c index 38a08135..6d19c82c 100644 --- a/src/version.c +++ b/src/version.c @@ -715,6 +715,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 20, +/**/ 19, /**/ 18, |