aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/mark.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/mark.c')
-rw-r--r--src/nvim/mark.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 05f78c76bc..af404c354b 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -924,7 +924,7 @@ static void mark_adjust_internal(linenr_T line1, linenr_T line2,
int i;
int fnum = curbuf->b_fnum;
linenr_T *lp;
- static pos_T initpos = INIT_POS_T(1, 0, 0);
+ static pos_T initpos = { 1, 0, 0 };
if (line2 < line1 && amount_after == 0L) /* nothing to do */
return;
@@ -1069,19 +1069,24 @@ static void mark_adjust_internal(linenr_T line1, linenr_T line2,
{ \
posp->lnum += lnum_amount; \
assert(col_amount > INT_MIN && col_amount <= INT_MAX); \
- if (col_amount < 0 && posp->col <= (colnr_T)-col_amount) \
+ if (col_amount < 0 && posp->col <= (colnr_T)-col_amount) { \
posp->col = 0; \
- else \
+ } else if (posp->col < spaces_removed) { \
+ posp->col = (int)col_amount + spaces_removed; \
+ } else { \
posp->col += (colnr_T)col_amount; \
+ } \
} \
}
-/*
- * 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.
- */
-void mark_col_adjust(linenr_T lnum, colnr_T mincol, long lnum_amount, long col_amount)
+// 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,
+ int spaces_removed)
{
int i;
int fnum = curbuf->b_fnum;