aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/cursor.c
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2020-07-31 17:59:48 -0400
committerJames McCoy <jamessan@jamessan.com>2020-07-31 17:59:48 -0400
commit228d7d948200563292f13723cdd0f947bd0c711c (patch)
treee30ac7afb5cfc68470be42e8c5e02907fb44b99b /src/nvim/cursor.c
parent3e3002b90c46fca8d8d5edebc021e56d95c5e645 (diff)
parent1153ac9036ab62ee25078248a01dc56a2311b9a6 (diff)
downloadrneovim-228d7d948200563292f13723cdd0f947bd0c711c.tar.gz
rneovim-228d7d948200563292f13723cdd0f947bd0c711c.tar.bz2
rneovim-228d7d948200563292f13723cdd0f947bd0c711c.zip
Merge remote-tracking branch 'upstream/master' into fileinfo-garbage
Diffstat (limited to 'src/nvim/cursor.c')
-rw-r--r--src/nvim/cursor.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c
index f2b3cfe690..036ae32589 100644
--- a/src/nvim/cursor.c
+++ b/src/nvim/cursor.c
@@ -93,11 +93,12 @@ int coladvance(colnr_T wcol)
static int coladvance2(
pos_T *pos,
- bool addspaces, /* change the text to achieve our goal? */
- bool finetune, /* change char offset for the exact column */
- colnr_T wcol /* column to move to */
+ bool addspaces, // change the text to achieve our goal?
+ bool finetune, // change char offset for the exact column
+ colnr_T wcol_arg // column to move to (can be negative)
)
{
+ colnr_T wcol = wcol_arg;
int idx;
char_u *ptr;
char_u *line;
@@ -165,6 +166,7 @@ static int coladvance2(
if (virtual_active()
&& addspaces
+ && wcol >= 0
&& ((col != wcol && col != wcol + 1) || csize > 1)) {
/* 'virtualedit' is set: The difference between wcol and col is
* filled with spaces. */
@@ -244,8 +246,9 @@ static int coladvance2(
mark_mb_adjustpos(curbuf, pos);
}
- if (col < wcol)
+ if (wcol < 0 || col < wcol) {
return FAIL;
+ }
return OK;
}