To: vim_dev@googlegroups.com Subject: Patch 9.0.0709 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0709 Problem: Virtual text "after" not correct with 'nowrap'. Solution: Do not display "after" text prop on the next line when 'wrap' is off. Files: src/drawline.c, src/proto/drawline.pro, src/charset.c, src/testdir/test_textprop.vim, src/testdir/dumps/Test_text_after_nowrap_1.dump *** ../vim-9.0.0708/src/drawline.c 2022-10-09 15:25:45.949815094 +0100 --- src/drawline.c 2022-10-09 21:06:35.551623190 +0100 *************** *** 612,618 **** text_prop_position( win_T *wp, textprop_T *tp, ! int vcol, // current screen column int *n_extra, // nr of bytes for virtual text char_u **p_extra, // virtual text int *n_attr, // attribute cells, NULL if not used --- 612,619 ---- text_prop_position( win_T *wp, textprop_T *tp, ! int vcol UNUSED, // current text column ! int scr_col, // current screen column int *n_extra, // nr of bytes for virtual text char_u **p_extra, // virtual text int *n_attr, // attribute cells, NULL if not used *************** *** 624,630 **** int wrap = (tp->tp_flags & TP_FLAG_WRAP); int padding = tp->tp_col == MAXCOL && tp->tp_len > 1 ? tp->tp_len - 1 : 0; ! int col_with_padding = vcol + (below ? 0 : padding); int room = wp->w_width - col_with_padding; int before = room; // spaces before the text int after = 0; // spaces after the text --- 625,631 ---- int wrap = (tp->tp_flags & TP_FLAG_WRAP); int padding = tp->tp_col == MAXCOL && tp->tp_len > 1 ? tp->tp_len - 1 : 0; ! int col_with_padding = scr_col + (below ? 0 : padding); int room = wp->w_width - col_with_padding; int before = room; // spaces before the text int after = 0; // spaces after the text *************** *** 1888,1908 **** for (pi = 0; pi < text_props_active; ++pi) { int tpi = text_prop_idxs[pi]; proptype_T *pt = text_prop_type_by_id( ! wp->w_buffer, text_props[tpi].tp_type); if (pt != NULL && (pt->pt_hl_id > 0 ! || text_props[tpi].tp_id < 0) ! && text_props[tpi].tp_id != -MAXCOL) { if (pt->pt_hl_id > 0) used_attr = syn_id2attr(pt->pt_hl_id); text_prop_type = pt; text_prop_attr = hl_combine_attr(text_prop_attr, used_attr); - text_prop_flags = pt->pt_flags; - text_prop_id = text_props[tpi].tp_id; other_tpi = used_tpi; used_tpi = tpi; } } --- 1889,1909 ---- for (pi = 0; pi < text_props_active; ++pi) { int tpi = text_prop_idxs[pi]; + textprop_T *tp = &text_props[tpi]; proptype_T *pt = text_prop_type_by_id( ! wp->w_buffer, tp->tp_type); if (pt != NULL && (pt->pt_hl_id > 0 ! || tp->tp_id < 0) && tp->tp_id != -MAXCOL) { if (pt->pt_hl_id > 0) used_attr = syn_id2attr(pt->pt_hl_id); text_prop_type = pt; text_prop_attr = hl_combine_attr(text_prop_attr, used_attr); other_tpi = used_tpi; + text_prop_flags = pt->pt_flags; + text_prop_id = tp->tp_id; used_tpi = tpi; } } *************** *** 1972,1977 **** --- 1973,1979 ---- // Shared with win_lbr_chartabsize(), must do // exactly the same. start_line = text_prop_position(wp, tp, + wlv.vcol, wlv.col, &wlv.n_extra, &wlv.p_extra, &n_attr, &n_attr_skip); *************** *** 2011,2017 **** // If this is an "above" text prop and 'nowrap' the we // must wrap anyway. text_prop_above = above; ! text_prop_follows = other_tpi != -1; } } else if (text_prop_next < text_prop_count --- 2013,2022 ---- // If this is an "above" text prop and 'nowrap' the we // must wrap anyway. text_prop_above = above; ! text_prop_follows = other_tpi != -1 ! && (wp->w_p_wrap ! || (text_props[other_tpi].tp_flags ! & (TP_FLAG_ALIGN_BELOW | TP_FLAG_ALIGN_RIGHT))); } } else if (text_prop_next < text_prop_count *** ../vim-9.0.0708/src/proto/drawline.pro 2022-08-23 18:39:14.760797662 +0100 --- src/proto/drawline.pro 2022-10-09 20:17:09.490430639 +0100 *************** *** 1,4 **** /* drawline.c */ ! int text_prop_position(win_T *wp, textprop_T *tp, int vcol, int *n_extra, char_u **p_extra, int *n_attr, int *n_attr_skip); int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int nochange, int number_only); /* vim: set ft=c : */ --- 1,4 ---- /* drawline.c */ ! int text_prop_position(win_T *wp, textprop_T *tp, int vcol, int scr_col, int *n_extra, char_u **p_extra, int *n_attr, int *n_attr_skip); int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, int nochange, int number_only); /* vim: set ft=c : */ *** ../vim-9.0.0708/src/charset.c 2022-09-17 17:15:02.447654060 +0100 --- src/charset.c 2022-10-09 20:14:00.538880550 +0100 *************** *** 1178,1184 **** { int n_extra = (int)STRLEN(p); ! cells = text_prop_position(wp, tp, (vcol + size) % (wp->w_width - col_off) + col_off, &n_extra, &p, NULL, NULL); #ifdef FEAT_LINEBREAK --- 1178,1184 ---- { int n_extra = (int)STRLEN(p); ! cells = text_prop_position(wp, tp, vcol, (vcol + size) % (wp->w_width - col_off) + col_off, &n_extra, &p, NULL, NULL); #ifdef FEAT_LINEBREAK *** ../vim-9.0.0708/src/testdir/test_textprop.vim 2022-10-09 15:25:45.949815094 +0100 --- src/testdir/test_textprop.vim 2022-10-09 21:51:06.863348668 +0100 *************** *** 3211,3216 **** --- 3211,3246 ---- call StopVimInTerminal(buf) endfunc + func Test_text_after_nowrap() + CheckRunVimInTerminal + + " FIXME: the second property causes a hang + let lines =<< trim END + vim9script + setline(1, ['first line', 'second line '->repeat(50), 'third', 'fourth']) + set nowrap + prop_type_add('theprop', {highlight: 'DiffChange'}) + prop_add(1, 0, { + type: 'theprop', + text: 'after the text '->repeat(5), + text_align: 'after', + text_padding_left: 2, + }) + #prop_add(1, 0, { + # type: 'theprop', + # text: 'after the text '->repeat(5), + # text_align: 'after', + # text_padding_left: 2, + #}) + normal 2Gw + END + call writefile(lines, 'XTextAfterNowrap', 'D') + let buf = RunVimInTerminal('-S XTextAfterNowrap', #{rows: 8, cols: 60}) + call VerifyScreenDump(buf, 'Test_text_after_nowrap_1', {}) + + call StopVimInTerminal(buf) + endfunc + func Test_insert_text_change_arg() CheckRunVimInTerminal *** ../vim-9.0.0708/src/testdir/dumps/Test_text_after_nowrap_1.dump 2022-10-09 21:52:41.451365647 +0100 --- src/testdir/dumps/Test_text_after_nowrap_1.dump 2022-10-09 21:07:45.871042852 +0100 *************** *** 0 **** --- 1,8 ---- + |f+0&#ffffff0|i|r|s|t| |l|i|n|e| @1|a+0&#ffd7ff255|f|t|e|r| |t|h|e| |t|e|x|t| |a|f|t|e|r| |t|h|e| |t|e|x|t| |a|f|t|e|r| |t|h|e| |t|e|x|t| |a|f|t + |s+0&#ffffff0|e|c|o|n|d| >l|i|n|e| |s|e|c|o|n|d| |l|i|n|e| |s|e|c|o|n|d| |l|i|n|e| |s|e|c|o|n|d| |l|i|n|e| |s|e|c|o|n|d| |l|i|n|e| + |t|h|i|r|d| @54 + |f|o|u|r|t|h| @53 + |~+0#4040ff13&| @58 + |~| @58 + |~| @58 + | +0#0000000&@41|2|,|8| @10|A|l@1| *** ../vim-9.0.0708/src/version.c 2022-10-09 18:53:29.024591198 +0100 --- src/version.c 2022-10-09 21:08:40.014629008 +0100 *************** *** 701,702 **** --- 701,704 ---- { /* Add new patch number below this line */ + /**/ + 709, /**/ -- ARTHUR: Will you ask your master if he wants to join my court at Camelot?! GUARD #1: But then of course African swallows are not migratory. GUARD #2: Oh, yeah... GUARD #1: So they couldn't bring a coconut back anyway... The Quest for the Holy Grail (Monty Python) /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///