diff options
author | bfredl <bjorn.linse@gmail.com> | 2023-05-09 14:26:03 +0200 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2023-05-22 13:49:42 +0200 |
commit | a78fd18ed92d7474d10b5640dcf7a15728d2e03a (patch) | |
tree | 9123221c9391e661771288d03fdfa704b003ef13 /src/nvim/charset.c | |
parent | 29da1a9cf0b44f2edcbff9e45af283f235360947 (diff) | |
download | rneovim-a78fd18ed92d7474d10b5640dcf7a15728d2e03a.tar.gz rneovim-a78fd18ed92d7474d10b5640dcf7a15728d2e03a.tar.bz2 rneovim-a78fd18ed92d7474d10b5640dcf7a15728d2e03a.zip |
fix(extmark): fix cursor position with both left and right gravity inline text
Diffstat (limited to 'src/nvim/charset.c')
-rw-r--r-- | src/nvim/charset.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 2917bb31ee..49890a460a 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1053,11 +1053,8 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en // make sure we don't go past the end of the line if (*cts.cts_ptr == NUL) { - // NUL at end of line only takes one column - incr = 1; - if (cts.cts_cur_text_width > 0) { - incr = cts.cts_cur_text_width; - } + // NUL at end of line only takes one column, unless there is virtual text + incr = MAX(1, cts.cts_cur_text_width_left + cts.cts_cur_text_width_right); on_NUL = true; break; } @@ -1092,9 +1089,12 @@ 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 || !cts.cts_has_right_gravity) && !on_NUL) { + if (!on_NUL) { // cursor is after inserted text, unless on the NUL - vcol += cts.cts_cur_text_width; + vcol += cts.cts_cur_text_width_left; + if ((State & MODE_INSERT) == 0) { + vcol += cts.cts_cur_text_width_right; + } } // cursor at start *cursor = vcol + head; |