Skip to content

Commit 6b36d2a

Browse files
committed
patch 8.2.3369: auto formatting after "cw" leaves cursor in wrong spot
Problem: Auto formatting after "cw" leaves cursor in wrong spot. Solution: Do not auto-format after the delete. (closes #8789)
1 parent 9cd91a1 commit 6b36d2a

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/ops.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,8 @@ op_delete(oparg_T *oap)
942942
curwin->w_cursor = curpos; // restore curwin->w_cursor
943943
(void)do_join(2, FALSE, FALSE, FALSE, FALSE);
944944
}
945-
auto_format(FALSE, TRUE);
945+
if (oap->op_type == OP_DELETE)
946+
auto_format(FALSE, TRUE);
946947
}
947948

948949
msgmore(curbuf->b_ml.ml_line_count - old_lcount);
@@ -1809,6 +1810,7 @@ op_change(oparg_T *oap)
18091810
vim_free(ins_text);
18101811
}
18111812
}
1813+
auto_format(FALSE, TRUE);
18121814

18131815
return retval;
18141816
}

src/testdir/test_textformat.vim

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,13 @@ func Test_fo_a_w()
967967
exe "normal f4xx"
968968
call assert_equal(['1 2 5 6 7 ', '8 9'], getline(1, 2))
969969

970+
" using "cw" leaves cursor in right spot
971+
call setline(1, ['Now we g whether that nation, or',
972+
\ 'any nation so conceived and,'])
973+
set fo=tcqa tw=35
974+
exe "normal 2G0cwx\<Esc>"
975+
call assert_equal(['Now we g whether that nation, or x', 'nation so conceived and,'], getline(1, 2))
976+
970977
set tw=0
971978
set fo&
972979
%bw!

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3369,
758760
/**/
759761
3368,
760762
/**/

0 commit comments

Comments
 (0)