Mercurial > vim
changeset 30773:fc9993c5835a v9.0.0721
patch 9.0.0721: virtual text "above" with padding not displayed correctly
Commit: https://github.com/vim/vim/commit/9466fb8001227a4bc9045e91045426bc40680366
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Oct 11 14:54:42 2022 +0100
patch 9.0.0721: virtual text "above" with padding not displayed correctly
Problem: Virtual text "above" with padding not displayed correctly.
Solution: Take padding into account when truncating. (closes https://github.com/vim/vim/issues/11340)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 11 Oct 2022 16:00:05 +0200 |
parents | 73a1f2dec989 |
children | cf413cc04043 |
files | src/drawline.c src/testdir/dumps/Test_prop_with_text_above_9.dump src/testdir/test_textprop.vim src/version.c |
diffstat | 4 files changed, 21 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/drawline.c +++ b/src/drawline.c @@ -459,7 +459,7 @@ handle_lnum_col( handle_breakindent(win_T *wp, winlinevars_T *wlv) { if (wp->w_briopt_sbr && wlv->draw_state == WL_BRI - 1 - && *get_showbreak_value(wp) != NUL) + && *get_showbreak_value(wp) != NUL) // draw indent after showbreak value wlv->draw_state = WL_BRI; else if (wp->w_briopt_sbr && wlv->draw_state == WL_SBR) @@ -586,7 +586,7 @@ textprop_size_after_trunc( // if the remaining size is to small wrap anyway and use the next line if (space < PROP_TEXT_MIN_CELLS) space += wp->w_width; - if (flags & TP_FLAG_ALIGN_BELOW) + if (flags & (TP_FLAG_ALIGN_BELOW | TP_FLAG_ALIGN_ABOVE)) space -= padding; for (n_used = 0; n_used < len; n_used += (*mb_ptr2len)(text + n_used)) {
new file mode 100644 --- /dev/null +++ b/src/testdir/dumps/Test_prop_with_text_above_9.dump @@ -0,0 +1,9 @@ +| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@3|f+0#0000000#ffff4012|i|r|s|t| |t|h|i|n|g| |a|b|o|v|e| +0&#ffffff0@36 +| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@3|s+0#0000000#ffd7ff255|e|c|o|n|d| |t|h|i|n|g| |a|b|o|v|e| +0&#ffffff0@35 +| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@3| +0#0000000&@1|0+0&#ffff4012| |1| |2| |3| |4| |5| |6| |7| |8| |9| |1|0| |1@1| |1|2| |1|3| |1|4| |1|5| |1|6| |1|7| |1|8| |1|9| |2|… +| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@1|1| |i+0#0000000&|n|s|e|r|t|e|d| @45 +| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@1|2| >o+0#0000000&|n|e| |t|w|o| @46 +| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@3|b+0#0000000#5fd7ff255|e|l|o|w| +0&#ffffff0@48 +|~+0#4040ff13&| @58 +|~| @58 +|:+0#0000000&|c|a|l@1| |A|d@1|L|o|n|g|P|r|o|p|A|b|o|v|e|(|)| @17|2|,|1| @10|A|l@1|
--- a/src/testdir/test_textprop.vim +++ b/src/testdir/test_textprop.vim @@ -2852,6 +2852,11 @@ func Test_props_with_text_above() func AddPropBelow() call prop_add(1, 0, #{type: 'below', text: 'below', text_align: 'below'}) endfunc + func AddLongPropAbove() + 3,4delete + set wrap + call prop_add(1, 0, #{type: 'above1', text: range(50)->join(' '), text_align: 'above', text_padding_left: 2}) + endfunc END call writefile(lines, 'XscriptPropsWithTextAbove', 'D') let buf = RunVimInTerminal('-S XscriptPropsWithTextAbove', #{rows: 9, cols: 60}) @@ -2887,6 +2892,9 @@ func Test_props_with_text_above() call term_sendkeys(buf, "\<Esc>ls\<CR>\<Esc>") call VerifyScreenDump(buf, 'Test_prop_with_text_above_8', {}) + call term_sendkeys(buf, ":call AddLongPropAbove()\<CR>") + call VerifyScreenDump(buf, 'Test_prop_with_text_above_9', {}) + call StopVimInTerminal(buf) endfunc