commit e12b5882af97126a9525a74a0955cc9e0f9114a9
parent dee3af2122d5072d351551ef023d2c177334b332
Author: Ibby <33922797+SleepySwords@users.noreply.github.com>
Date: Sun, 26 Mar 2023 17:40:07 +1100
vim-patch:9.0.0183: extra space after virtual text when 'linebreak' is set
Problem: Extra space after virtual text when 'linebreak' is set.
Solution: Do not count virtual text when getting linebreak value.
(closes vim/vim#10884)
https://github.com/vim/vim/commit/52de3a8d3943520bbd4e5e40a4c43fcc7182dac0
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat:
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git 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
@@ -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()