diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-12-31 23:58:24 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-12-31 23:58:24 +0100 |
commit | e1e714ef0d1f4bb8b1712795e9106e3b4ff4c7bd (patch) | |
tree | a8140991365c6a83af9d501ef7e471dc0c9160d4 /src/mark.c | |
parent | 3d631cb0b34b03c7bdf45ad852d3644c7cf62743 (diff) | |
download | vim-git-e1e714ef0d1f4bb8b1712795e9106e3b4ff4c7bd.tar.gz |
patch 8.1.0671: cursor in the wrong column after auto-formattingv8.1.0671
Problem: Cursor in the wrong column after auto-formatting.
Solution: Check for deleting more spaces than adding. (closes #3748)
Diffstat (limited to 'src/mark.c')
-rw-r--r-- | src/mark.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mark.c b/src/mark.c index f9e3ce3cf..e3e209c4a 100644 --- a/src/mark.c +++ b/src/mark.c @@ -1211,6 +1211,8 @@ mark_adjust_internal( posp->lnum += lnum_amount; \ if (col_amount < 0 && posp->col <= (colnr_T)-col_amount) \ posp->col = 0; \ + else if (posp->col < spaces_removed) \ + posp->col = col_amount + spaces_removed; \ else \ posp->col += col_amount; \ } \ @@ -1220,13 +1222,16 @@ mark_adjust_internal( * Adjust marks in line "lnum" at column "mincol" and further: add * "lnum_amount" to the line number and add "col_amount" to the column * position. + * "spaces_removed" is the number of spaces that were removed, matters when the + * cursor is inside them. */ void mark_col_adjust( linenr_T lnum, colnr_T mincol, long lnum_amount, - long col_amount) + long col_amount, + int spaces_removed) { int i; int fnum = curbuf->b_fnum; |