aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIbby <33922797+SleepySwords@users.noreply.github.com>2023-03-26 00:10:28 +1100
committerbfredl <bjorn.linse@gmail.com>2023-05-22 13:49:42 +0200
commit8eaf3c4f8c2ee4dc5a6e12bb809058ad263dbb65 (patch)
tree31f1f982dab52f8235db677ee43451a996067f32
parent0c7fa3bdcc3761cc851ea0ac37bf692b990044cc (diff)
downloadrneovim-8eaf3c4f8c2ee4dc5a6e12bb809058ad263dbb65.tar.gz
rneovim-8eaf3c4f8c2ee4dc5a6e12bb809058ad263dbb65.tar.bz2
rneovim-8eaf3c4f8c2ee4dc5a6e12bb809058ad263dbb65.zip
vim-patch:9.0.0143: cursor positioned after virtual text in empty line
Problem: Cursor positioned after virtual text in empty line. Solution: Keep cursor in the first column. (closes vim/vim#10786) https://github.com/vim/vim/commit/afd2aa79eda3fe69f2e7c87d0b9b4bca874f386a
-rw-r--r--src/nvim/plines.c2
-rw-r--r--test/functional/ui/decorations_spec.lua22
2 files changed, 23 insertions, 1 deletions
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index dd4955c352..1c6ed4f4c1 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -390,7 +390,7 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
// First get normal size, without 'linebreak' or virtual text
int size = win_chartabsize(wp, s, vcol);
- if (cts->cts_has_virt_text) {
+ if (cts->cts_has_virt_text && *line != NUL) {
int col = (int)(s - line);
while (true) {
mtkey_t mark = marktree_itr_current(cts->cts_iter);
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua
index 6e4b19c856..a2b0138da3 100644
--- a/test/functional/ui/decorations_spec.lua
+++ b/test/functional/ui/decorations_spec.lua
@@ -1368,6 +1368,28 @@ end]]
{24:-- INSERT --} |
]]}
end)
+
+ it('has correct cursor position with virtual text on an empty line', function()
+ meths.buf_set_extmark(0, ns, 0, 0,
+ { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' })
+ screen:expect { grid = [[
+ {28:^virtual text} |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]]}
+ end)
end)
describe('decorations: virtual lines', function()