diff options
author | Ibby <33922797+SleepySwords@users.noreply.github.com> | 2023-03-26 17:40:07 +1100 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2023-05-22 13:49:42 +0200 |
commit | e12b5882af97126a9525a74a0955cc9e0f9114a9 (patch) | |
tree | c7575c34fb005926daf98cbdd76aa53e39f28ea3 | |
parent | dee3af2122d5072d351551ef023d2c177334b332 (diff) | |
download | rneovim-e12b5882af97126a9525a74a0955cc9e0f9114a9.tar.gz rneovim-e12b5882af97126a9525a74a0955cc9e0f9114a9.tar.bz2 rneovim-e12b5882af97126a9525a74a0955cc9e0f9114a9.zip |
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>
-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() |