aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/charset.c2
-rw-r--r--src/nvim/plines.c2
-rw-r--r--src/nvim/plines.h1
3 files changed, 4 insertions, 1 deletions
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 24267ebd50..2917bb31ee 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -1092,7 +1092,7 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en
// cursor at end
*cursor = vcol + incr - 1;
} else {
- if ((State & MODE_INSERT) == 0 && !on_NUL) {
+ if (((State & MODE_INSERT) == 0 || !cts.cts_has_right_gravity) && !on_NUL) {
// cursor is after inserted text, unless on the NUL
vcol += cts.cts_cur_text_width;
}
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index 2df9c23902..3b4883d5c2 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -325,6 +325,7 @@ void init_chartabsize_arg(chartabsize_T *cts, win_T *wp, linenr_T lnum, colnr_T
cts->cts_ptr = ptr;
cts->cts_cur_text_width = 0;
cts->cts_has_virt_text = false;
+ cts->cts_has_right_gravity = true;
cts->cts_row = lnum - 1;
if (cts->cts_row >= 0) {
@@ -425,6 +426,7 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
Decoration decor = get_decor(mark);
if (decor.virt_text_pos == kVTInline) {
cts->cts_cur_text_width += decor.virt_text_width;
+ cts->cts_has_right_gravity = mt_right(mark);
size += decor.virt_text_width;
if (*s == TAB) {
// tab size changes because of the inserted text
diff --git a/src/nvim/plines.h b/src/nvim/plines.h
index a15c234bba..6e4768bc7d 100644
--- a/src/nvim/plines.h
+++ b/src/nvim/plines.h
@@ -14,6 +14,7 @@ typedef struct {
int cts_row;
bool cts_has_virt_text; // true if if a property inserts text
+ bool cts_has_right_gravity;
int cts_cur_text_width; // width of current inserted text
MarkTreeIter cts_iter[1];
// TODO(bfredl): iterator in to the marktree for scanning virt text