aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/charset.c
diff options
context:
space:
mode:
authorIbby <33922797+SleepySwords@users.noreply.github.com>2023-03-26 14:49:09 +1100
committerbfredl <bjorn.linse@gmail.com>2023-05-22 13:49:42 +0200
commit43c2eaada220d5e7d44fa9086655b00ee3e5fbb5 (patch)
tree61fdf8837fdb03d17127a6692f0cd7050b528970 /src/nvim/charset.c
parent8eaf3c4f8c2ee4dc5a6e12bb809058ad263dbb65 (diff)
downloadrneovim-43c2eaada220d5e7d44fa9086655b00ee3e5fbb5.tar.gz
rneovim-43c2eaada220d5e7d44fa9086655b00ee3e5fbb5.tar.bz2
rneovim-43c2eaada220d5e7d44fa9086655b00ee3e5fbb5.zip
vim-patch:9.0.0179: cursor pos wrong with wrapping virtual text in empty line
Problem: Cursor position wrong with wrapping virtual text in empty line. Solution: Adjust handling of an empty line. (closes vim/vim#10875) https://github.com/vim/vim/commit/49a90792d950c51608d0459ef8699fe921070718 Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/charset.c')
-rw-r--r--src/nvim/charset.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 48a38dd3d3..3b48392d49 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -989,6 +989,7 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en
}
chartabsize_T cts;
+ bool on_NUL = false;
init_chartabsize_arg(&cts, wp, pos->lnum, 0, line, line);
// This function is used very often, do some speed optimizations.
@@ -1054,6 +1055,10 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en
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;
+ }
+ on_NUL = true;
break;
}
@@ -1079,8 +1084,8 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en
}
if (cursor != NULL) {
- if ((State & MODE_INSERT) == 0) {
- // cursor is after inserted text
+ if ((State & MODE_INSERT) == 0 && !on_NUL) {
+ // cursor is after inserted text, unless on the NUL
vcol += cts.cts_cur_text_width;
}
if ((*ptr == TAB)