# HG changeset patch # User Christian Brabandt # Date 1702217768 -3600 # Node ID 25e5297fbc72955617dc57b030d78f3087a8b256 # Parent c80400d7f7fe2caa6b1ecd11d86eb45fa40a8cf2 patch 9.0.2144: Text properties causes wrong line wrapping Commit: https://github.com/vim/vim/commit/4e26a9aab6ad0ceb6bab0fd70e1031abb429f233 Author: zeertzjq Date: Sun Dec 3 17:50:47 2023 +0100 patch 9.0.2144: Text properties causes wrong line wrapping Problem: Text properties causes wrong line wrapping to be drawn. Solution: Find the index of the last text property that inserts text. closes: #13611 Signed-off-by: zeertzjq Signed-off-by: Christian Brabandt diff --git a/src/drawline.c b/src/drawline.c --- a/src/drawline.c +++ b/src/drawline.c @@ -1149,6 +1149,7 @@ win_line( #ifdef FEAT_PROP_POPUP int did_line = FALSE; // set to TRUE when line text done int text_prop_count; + int last_textprop_text_idx = -1; int text_prop_next = 0; // next text property to use textprop_T *text_props = NULL; int *text_prop_idxs = NULL; @@ -1616,6 +1617,11 @@ win_line( area_highlighting = TRUE; extra_check = TRUE; + /* Find the last text property that inserts text. */ + for (int i = 0; i < text_prop_count; ++i) + if (text_props[i].tp_id < 0) + last_textprop_text_idx = i; + // When skipping virtual text the props need to be sorted. The // order is reversed! if (lnum == wp->w_topline && wp->w_skipcol > 0) @@ -3791,7 +3797,7 @@ win_line( || (wlv.n_extra > 0 && (wlv.c_extra != NUL || *wlv.p_extra != NUL)) #ifdef FEAT_PROP_POPUP - || text_prop_next < text_prop_count + || text_prop_next <= last_textprop_text_idx #endif )) { @@ -4083,7 +4089,7 @@ win_line( #endif #ifdef FEAT_PROP_POPUP || text_prop_above || text_prop_follows - || text_prop_next < text_prop_count + || text_prop_next <= last_textprop_text_idx #endif || (wp->w_p_list && wp->w_lcs_chars.eol != NUL && wlv.p_extra != at_end_str) diff --git a/src/testdir/dumps/Test_prop_in_empty_popup.dump b/src/testdir/dumps/Test_prop_in_empty_popup.dump new file mode 100644 --- /dev/null +++ b/src/testdir/dumps/Test_prop_in_empty_popup.dump @@ -0,0 +1,20 @@ +> +0&#ffffff0@39 +|~+0#4040ff13&| @38 +|~| @38 +|~| @38 +|~| @7|╔+0#0000000&|═@19|╗| +0#4040ff13&@8 +|~| @7|║+0#0000000&| +8#af5f00255&@1|1| | +8#e000002&@15|║+0#0000000&| +0#4040ff13&@8 +|~| @7|║+0#0000000&| +0#4040ff13&@19|║+0#0000000&| +0#4040ff13&@8 +|~| @7|║+0#0000000&| +0#4040ff13&@19|║+0#0000000&| +0#4040ff13&@8 +|~| @7|║+0#0000000&| +0#4040ff13&@19|║+0#0000000&| +0#4040ff13&@8 +|~| @7|║+0#0000000&| +0#4040ff13&@19|║+0#0000000&| +0#4040ff13&@8 +|~| @7|║+0#0000000&| +0#4040ff13&@19|║+0#0000000&| +0#4040ff13&@8 +|~| @7|║+0#0000000&| +0#4040ff13&@19|║+0#0000000&| +0#4040ff13&@8 +|~| @7|║+0#0000000&| +0#4040ff13&@19|║+0#0000000&| +0#4040ff13&@8 +|~| @7|║+0#0000000&| +0#4040ff13&@19|║+0#0000000&| +0#4040ff13&@8 +|~| @7|║+0#0000000&| +0#4040ff13&@19|║+0#0000000&| +0#4040ff13&@8 +|~| @7|╚+0#0000000&|═@19|╝| +0#4040ff13&@8 +|~| @38 +|~| @38 +|~| @38 +| +0#0000000&@21|0|,|0|-|1| @8|A|l@1| diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim --- a/src/testdir/test_textprop.vim +++ b/src/testdir/test_textprop.vim @@ -1424,6 +1424,43 @@ func Test_textprop_text_priority() call StopVimInTerminal(buf) endfunc +func Test_textprop_in_empty_popup() + CheckScreendump + + let lines =<< trim END + vim9script + + hi def link FilterMenuMatch Constant + prop_type_add('FilterMenuMatch', { + highlight: "FilterMenuMatch", + override: true, + priority: 1000, + combine: true, + }) + + var winid = popup_create([{text: "hello", props: [ + {col: 1, length: 1, type: 'FilterMenuMatch'}, + {col: 2, length: 1, type: 'FilterMenuMatch'}, + ]}], { + minwidth: 20, + minheight: 10, + cursorline: false, + highlight: "None", + border: [], + }) + + win_execute(winid, "setl nu cursorline cursorlineopt=both") + popup_settext(winid, []) + redraw + END + call writefile(lines, 'XtestPropEmptyPopup', 'D') + let buf = RunVimInTerminal('-S XtestPropEmptyPopup', #{rows: 20, cols: 40}) + call VerifyScreenDump(buf, 'Test_prop_in_empty_popup', {}) + + " clean up + call StopVimInTerminal(buf) +endfunc + func Test_textprop_with_syntax() CheckScreendump diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -705,6 +705,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2144, +/**/ 2143, /**/ 2142,