diff options
-rw-r--r-- | src/nvim/drawline.c | 4 | ||||
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 25 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/nvim/drawline.c b/src/nvim/drawline.c index e42d912dbe..725b047985 100644 --- a/src/nvim/drawline.c +++ b/src/nvim/drawline.c @@ -2165,7 +2165,10 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, chartabsize_T cts; init_chartabsize_arg(&cts, wp, lnum, wlv.vcol, line, p); + // do not want virtual text to be counted here + cts.cts_has_virt_text = false; wlv.n_extra = win_lbr_chartabsize(&cts, NULL) - 1; + clear_chartabsize_arg(&cts); // We have just drawn the showbreak value, no need to add // space for it again. @@ -2197,7 +2200,6 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange, c = ' '; } } - clear_chartabsize_arg(&cts); } in_multispace = c == ' ' && ((ptr > line + 1 && ptr[-2] == ' ') || *ptr == ' '); diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 91284e3a2f..4ed9d5a044 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -1581,6 +1581,31 @@ bbbbbbb]]) | ]]} end) + + it('has correct cursor position with virtual text on an empty line', function() + command('set linebreak') + insert('one twoword') + feed('0') + meths.buf_set_extmark(0, ns, 0, 3, + { virt_text = { { ': virtual text', 'Special' } }, virt_text_pos = 'inline' }) + screen:expect { grid = [[ + ^one{28:: virtual text} twoword | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end) end) describe('decorations: virtual lines', function() |