From 98b373075e9a2ed642bc89f4f543e31d1428466f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 14 Sep 2022 12:06:53 +0100 Subject: [PATCH 1/8] patch 9.0.0462: ASAN warning for integer overflow Problem: ASAN warning for integer overflow. Solution: Check for tp_col to be MAXCOL. --- src/textprop.c | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/textprop.c b/src/textprop.c index d2536ce776..ba21e751bf 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -2289,7 +2289,7 @@ adjust_props_for_split( *p = prop; ++prevprop.ga_len; - if (p->tp_col + p->tp_len >= kept) + if (p->tp_col != MAXCOL && p->tp_col + p->tp_len >= kept) p->tp_len = kept - p->tp_col; if (cont_next) p->tp_flags |= TP_FLAG_CONT_NEXT; diff --git a/src/version.c b/src/version.c index 62a43a7087..f1805666c3 100644 --- a/src/version.c +++ b/src/version.c @@ -703,6 +703,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 462, /**/ 461, /**/ From febe13892ede37d2a8462b9921e05a55e059db0c Mon Sep 17 00:00:00 2001 From: Dominique Pelle Date: Wed, 14 Sep 2022 12:51:49 +0100 Subject: [PATCH 2/8] patch 9.0.0463: command line test leaves directory behind MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Command line test leaves directory behind. Solution: Use the "R" flag on the first mkdir(). (Dominique Pellé, closes #11127) --- src/testdir/test_cmdline.vim | 4 ++-- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim index 73bdbb4e66..7febc12269 100644 --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -2149,7 +2149,7 @@ func Test_wildmenu_pum() call VerifyScreenDump(buf, 'Test_wildmenu_pum_13', {}) " Directory name completion - call mkdir('Xnamedir/XdirA/XdirB', 'p') + call mkdir('Xnamedir/XdirA/XdirB', 'pR') call writefile([], 'Xnamedir/XfileA') call writefile([], 'Xnamedir/XdirA/XfileB') call writefile([], 'Xnamedir/XdirA/XdirB/XfileC') @@ -2229,7 +2229,7 @@ func Test_wildmenu_pum() call VerifyScreenDump(buf, 'Test_wildmenu_pum_31', {}) " Tests a directory name contained full-width characters. - call mkdir('Xnamedir/あいう', 'pR') + call mkdir('Xnamedir/あいう', 'p') call writefile([], 'Xnamedir/あいう/abc') call writefile([], 'Xnamedir/あいう/xyz') call writefile([], 'Xnamedir/あいう/123') diff --git a/src/version.c b/src/version.c index f1805666c3..1c2e49ffdf 100644 --- a/src/version.c +++ b/src/version.c @@ -703,6 +703,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 463, /**/ 462, /**/ From 702bd6c7c61073c0907fd7608911aebee4acd337 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 14 Sep 2022 16:09:57 +0100 Subject: [PATCH 3/8] patch 9.0.0464: with virtual text "above" indenting doesn't work well Problem: With virtual text "above" indenting doesn't work well. Solution: Ignore text properties while adjusting indent. (issue #11084) --- src/charset.c | 2 +- src/globals.h | 3 +++ src/indent.c | 6 ++++++ src/testdir/test_textprop.vim | 16 ++++++++++++++++ src/version.c | 2 ++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/charset.c b/src/charset.c index a19e55b628..c5edaf41e0 100644 --- a/src/charset.c +++ b/src/charset.c @@ -954,7 +954,7 @@ init_chartabsize_arg( cts->cts_line = line; cts->cts_ptr = ptr; #ifdef FEAT_PROP_POPUP - if (lnum > 0) + if (lnum > 0 && !ignore_text_props) { char_u *prop_start; int count; diff --git a/src/globals.h b/src/globals.h index 3d75e20d01..521832428a 100644 --- a/src/globals.h +++ b/src/globals.h @@ -755,6 +755,9 @@ EXTERN int popup_visible INIT(= FALSE); EXTERN int popup_uses_mouse_move INIT(= FALSE); EXTERN int text_prop_frozen INIT(= 0); + +// when TRUE computing the cursor position ignores text properties. +EXTERN int ignore_text_props INIT(= FALSE); #endif // When set the popup menu will redraw soon using the pum_win_ values. Do not diff --git a/src/indent.c b/src/indent.c index 134336c12d..51585ec9e8 100644 --- a/src/indent.c +++ b/src/indent.c @@ -1289,6 +1289,9 @@ change_indent( // for the following tricks we don't want list mode save_p_list = curwin->w_p_list; curwin->w_p_list = FALSE; +#ifdef FEAT_PROP_POPUP + ignore_text_props = TRUE; +#endif vc = getvcol_nolist(&curwin->w_cursor); vcol = vc; @@ -1440,6 +1443,9 @@ change_indent( ++start_col; } } +#ifdef FEAT_PROP_POPUP + ignore_text_props = FALSE; +#endif // For MODE_VREPLACE state, we also have to fix the replace stack. In this // case it is always possible because we backspace over the whole line and diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim index 5167e8e3b3..0a4037b9ef 100644 --- a/src/testdir/test_textprop.vim +++ b/src/testdir/test_textprop.vim @@ -2892,6 +2892,22 @@ func Test_props_with_text_above() call StopVimInTerminal(buf) endfunc +func Test_prop_above_with_indent() + new + call setline(1, ['first line', ' second line', ' line below']) + setlocal cindent + call prop_type_add('indented', #{highlight: 'Search'}) + call prop_add(3, 0, #{type: 'indented', text: 'here', text_align: 'above', text_padding_left: 4}) + call assert_equal(' line below', getline(3)) + + exe "normal 3G2|a\" + call assert_equal(' ', getline(3)) + call assert_equal(' line below', getline(4)) + + bwipe! + call prop_type_delete('indented') +endfunc + func Test_props_with_text_override() CheckRunVimInTerminal diff --git a/src/version.c b/src/version.c index 1c2e49ffdf..45afd9d027 100644 --- a/src/version.c +++ b/src/version.c @@ -703,6 +703,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 464, /**/ 463, /**/ From e697d488901b6321ddaad68b553f0a434c97d849 Mon Sep 17 00:00:00 2001 From: mityu Date: Wed, 14 Sep 2022 17:27:36 +0100 Subject: [PATCH 4/8] patch 9.0.0465: cursor moves when cmdwin is closed when 'splitscroll' is off Problem: Cursor moves when cmdwin is closed when 'splitscroll' is off. Solution: Temporarily set 'splitscroll' when jumping back to the original window. (closes #11128) --- src/ex_getln.c | 5 +++++ src/testdir/test_window_cmd.vim | 8 ++++++-- src/version.c | 2 ++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ex_getln.c b/src/ex_getln.c index f9226de6e4..4a5ac318e9 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -4405,6 +4405,7 @@ open_cmdwin(void) int save_restart_edit = restart_edit; int save_State = State; int save_exmode = exmode_active; + int save_p_spsc; #ifdef FEAT_RIGHTLEFT int save_cmdmsg_rl = cmdmsg_rl; #endif @@ -4643,7 +4644,11 @@ open_cmdwin(void) // First go back to the original window. wp = curwin; set_bufref(&bufref, curbuf); + + save_p_spsc = p_spsc; + p_spsc = TRUE; win_goto(old_curwin); + p_spsc = save_p_spsc; // win_goto() may trigger an autocommand that already closes the // cmdline window. diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim index c9f9caa347..872e1bac18 100644 --- a/src/testdir/test_window_cmd.vim +++ b/src/testdir/test_window_cmd.vim @@ -1734,9 +1734,13 @@ func Test_splitscroll_with_splits() above copen | wincmd j call assert_equal(win_screenpos(0)[0] - tabline, line("w0")) - " No scroll when opening cmdwin - only | norm ggLq: + " No scroll when opening cmdwin, and no cursor move when closing + " cmdwin. + only | norm ggL + let curpos = getcurpos() + norm q: call assert_equal(1, line("w0")) + call assert_equal(curpos, getcurpos()) " Scroll when cursor becomes invalid in insert mode norm Lic diff --git a/src/version.c b/src/version.c index 45afd9d027..cea4b7387b 100644 --- a/src/version.c +++ b/src/version.c @@ -703,6 +703,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 465, /**/ 464, /**/ From ebd0e8bb853cb744b60bf4f57011c4379ae4aaed Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 14 Sep 2022 22:13:59 +0100 Subject: [PATCH 5/8] patch 9.0.0466: virtual text wrong after adding line break after line Problem: Virtual text wrong after adding line break after line. Solution: Pass an "eol" flag to where text properties are adjusted. (closes #11131) --- src/change.c | 9 ++++++- src/proto/textprop.pro | 2 +- .../dumps/Test_prop_below_split_line_1.dump | 8 ++++++ src/testdir/test_textprop.vim | 26 +++++++++++++++++-- src/textprop.c | 25 ++++++++++++------ src/version.c | 2 ++ 6 files changed, 60 insertions(+), 12 deletions(-) create mode 100644 src/testdir/dumps/Test_prop_below_split_line_1.dump diff --git a/src/change.c b/src/change.c index b84dfad358..038f3c199f 100644 --- a/src/change.c +++ b/src/change.c @@ -1404,12 +1404,19 @@ open_line( int vreplace_mode; int did_append; // appended a new line int saved_pi = curbuf->b_p_pi; // copy of preserveindent setting +#ifdef FEAT_PROP_POPUP + int at_eol; // cursor after last character +#endif // make a copy of the current line so we can mess with it saved_line = vim_strsave(ml_get_curline()); if (saved_line == NULL) // out of memory! return FALSE; +#ifdef FEAT_PROP_POPUP + at_eol = curwin->w_cursor.col >= (int)STRLEN(saved_line); +#endif + if (State & VREPLACE_FLAG) { // With MODE_VREPLACE we make a copy of the next line, which we will be @@ -2133,7 +2140,7 @@ open_line( if ((State & MODE_INSERT) && (State & VREPLACE_FLAG) == 0) // Properties after the split move to the next line. adjust_props_for_split(curwin->w_cursor.lnum, curwin->w_cursor.lnum, - curwin->w_cursor.col + 1, 0); + curwin->w_cursor.col + 1, 0, at_eol); #endif } else diff --git a/src/proto/textprop.pro b/src/proto/textprop.pro index b3912c16ae..aa06e61f76 100644 --- a/src/proto/textprop.pro +++ b/src/proto/textprop.pro @@ -22,6 +22,6 @@ void f_prop_type_list(typval_T *argvars, typval_T *rettv); void clear_global_prop_types(void); void clear_buf_prop_types(buf_T *buf); int adjust_prop_columns(linenr_T lnum, colnr_T col, int bytes_added, int flags); -void adjust_props_for_split(linenr_T lnum_props, linenr_T lnum_top, int kept, int deleted); +void adjust_props_for_split(linenr_T lnum_props, linenr_T lnum_top, int kept, int deleted, int at_eol); void prepend_joined_props(char_u *new_props, int propcount, int *props_remaining, linenr_T lnum, int last_line, long col, int removed); /* vim: set ft=c : */ diff --git a/src/testdir/dumps/Test_prop_below_split_line_1.dump b/src/testdir/dumps/Test_prop_below_split_line_1.dump new file mode 100644 index 0000000000..671fceaf40 --- /dev/null +++ b/src/testdir/dumps/Test_prop_below_split_line_1.dump @@ -0,0 +1,8 @@ +|o+0&#ffffff0|n|e| |o|n|e| |o|n|e| @63 +|t|w|o| |t|w|o| |t|w|o| @63 +@3|└+2&&|─| |V|i|r|t|u|a|l| |t|e|x|t| |b|e|l|o|w| |t|h|e| |2|n|d| |l|i|n|e| +0&&@37 +|x@1> @72 +|t|h|r|e@1| |t|h|r|e@1| |t|h|r|e@1| @57 +|~+0#4040ff13&| @73 +|~| @73 +|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|3|,|3| @10|A|l@1| diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim index 0a4037b9ef..8a80e5504f 100644 --- a/src/testdir/test_textprop.vim +++ b/src/testdir/test_textprop.vim @@ -2908,6 +2908,29 @@ func Test_prop_above_with_indent() call prop_type_delete('indented') endfunc +func Test_prop_below_split_line() + CheckRunVimInTerminal + + let lines =<< trim END + vim9script + setline(1, ['one one one', 'two two two', 'three three three']) + prop_type_add('test', {highlight: 'ModeMsg'}) + prop_add(2, 0, { + text: '└─ Virtual text below the 2nd line', + type: 'test', + text_align: 'below', + text_padding_left: 3 + }) + END + call writefile(lines, 'XscriptPropBelowSpitLine', 'D') + let buf = RunVimInTerminal('-S XscriptPropBelowSpitLine', #{rows: 8}) + call term_sendkeys(buf, "2GA\xx") + call VerifyScreenDump(buf, 'Test_prop_below_split_line_1', {}) + + call term_sendkeys(buf, "\") + call StopVimInTerminal(buf) +endfunc + func Test_props_with_text_override() CheckRunVimInTerminal @@ -2920,7 +2943,7 @@ func Test_props_with_text_override() hi CursorLine cterm=underline ctermbg=lightgrey set cursorline END - call writefile(lines, 'XscriptPropsOverride') + call writefile(lines, 'XscriptPropsOverride', 'D') let buf = RunVimInTerminal('-S XscriptPropsOverride', #{rows: 6, cols: 60}) call VerifyScreenDump(buf, 'Test_prop_with_text_override_1', {}) @@ -2929,7 +2952,6 @@ func Test_props_with_text_override() call VerifyScreenDump(buf, 'Test_prop_with_text_override_2', {}) call StopVimInTerminal(buf) - call delete('XscriptPropsOverride') endfunc func Test_props_with_text_CursorMoved() diff --git a/src/textprop.c b/src/textprop.c index ba21e751bf..6e5c1447ff 100644 --- a/src/textprop.c +++ b/src/textprop.c @@ -2232,13 +2232,15 @@ adjust_prop_columns( * "lnum_top" is the top line. * "kept" is the number of bytes kept in the first line, while * "deleted" is the number of bytes deleted. + * "at_eol" is true if the split is after the end of the line. */ void adjust_props_for_split( - linenr_T lnum_props, - linenr_T lnum_top, - int kept, - int deleted) + linenr_T lnum_props, + linenr_T lnum_top, + int kept, + int deleted, + int at_eol) { char_u *props; int count; @@ -2276,9 +2278,16 @@ adjust_props_for_split( // a text prop "above" behaves like it is on the first text column prop_col = (prop.tp_flags & TP_FLAG_ALIGN_ABOVE) ? 1 : prop.tp_col; - cont_prev = prop_col != MAXCOL && prop_col + !start_incl <= kept; - cont_next = prop_col != MAXCOL - && skipped <= prop_col + prop.tp_len - !end_incl; + if (prop_col == MAXCOL) + { + cont_prev = at_eol; + cont_next = !at_eol; + } + else + { + cont_prev = prop_col + !start_incl <= kept; + cont_next = skipped <= prop_col + prop.tp_len - !end_incl; + } // when a prop has text it is never copied if (prop.tp_id < 0 && cont_next) cont_prev = FALSE; @@ -2297,7 +2306,7 @@ adjust_props_for_split( // Only add the property to the next line if the length is bigger than // zero. - if ((cont_next || prop_col == MAXCOL) && ga_grow(&nextprop, 1) == OK) + if (cont_next && ga_grow(&nextprop, 1) == OK) { textprop_T *p = ((textprop_T *)nextprop.ga_data) + nextprop.ga_len; diff --git a/src/version.c b/src/version.c index cea4b7387b..1aa99ae379 100644 --- a/src/version.c +++ b/src/version.c @@ -703,6 +703,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 466, /**/ 465, /**/ From d3922afbd6f56e82c7b5fd7a7ebc0769e416cae8 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 14 Sep 2022 22:30:59 +0100 Subject: [PATCH 6/8] patch 9.0.0467: build failure Problem: Build failure. Solution: Add missing change. --- src/ex_cmds.c | 3 ++- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 4938c6f485..ebcd441c81 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -4684,7 +4684,8 @@ ex_substitute(exarg_T *eap) last_line = lnum + 1; } #ifdef FEAT_PROP_POPUP - adjust_props_for_split(lnum + 1, lnum, plen, 1); + adjust_props_for_split(lnum + 1, lnum, + plen, 1, FALSE); #endif // all line numbers increase ++sub_firstlnum; diff --git a/src/version.c b/src/version.c index 1aa99ae379..6431957926 100644 --- a/src/version.c +++ b/src/version.c @@ -703,6 +703,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 467, /**/ 466, /**/ From aeef1f7f6d8f6d4e84ffc9a24874f10403e4ddcd Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 15 Sep 2022 12:20:18 +0100 Subject: [PATCH 7/8] patch 9.0.0468: exectution stack underflow without the +eval feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Exectution stack underflow without the +eval feature. (Dominique Pellé) Solution: Add to execution stack without FEAT_EVAL. (closes #11135) --- src/scriptfile.c | 3 +++ src/version.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/scriptfile.c b/src/scriptfile.c index 34683262a5..bdb7922363 100644 --- a/src/scriptfile.c +++ b/src/scriptfile.c @@ -1639,6 +1639,9 @@ do_source_ext( } } # endif +#else + // Keep the sourcing name/lnum, for recursive calls. + estack_push(ETYPE_SCRIPT, fname_exp, 0); #endif cookie.conv.vc_type = CONV_NONE; // no conversion diff --git a/src/version.c b/src/version.c index 6431957926..82a21df039 100644 --- a/src/version.c +++ b/src/version.c @@ -703,6 +703,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 468, /**/ 467, /**/ From 3735f11050616652525bf80b4fbcb2b3bfeab113 Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Thu, 15 Sep 2022 12:43:26 +0100 Subject: [PATCH 8/8] patch 9.0.0469: cursor moves if cmdwin is closed when 'splitscroll' is off Problem: Cursor moves if cmdwin is closed when 'splitscroll' is off. Solution: Skip win_fix_cursor if called when cmdwin is open or closing. (Luuk van Baal, closes #11134) --- src/ex_getln.c | 6 ++---- src/globals.h | 5 +++++ src/version.c | 2 ++ src/window.c | 4 ++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/ex_getln.c b/src/ex_getln.c index 4a5ac318e9..70436b31f0 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -4405,7 +4405,6 @@ open_cmdwin(void) int save_restart_edit = restart_edit; int save_State = State; int save_exmode = exmode_active; - int save_p_spsc; #ifdef FEAT_RIGHTLEFT int save_cmdmsg_rl = cmdmsg_rl; #endif @@ -4645,10 +4644,8 @@ open_cmdwin(void) wp = curwin; set_bufref(&bufref, curbuf); - save_p_spsc = p_spsc; - p_spsc = TRUE; + skip_win_fix_cursor = TRUE; win_goto(old_curwin); - p_spsc = save_p_spsc; // win_goto() may trigger an autocommand that already closes the // cmdline window. @@ -4662,6 +4659,7 @@ open_cmdwin(void) // Restore window sizes. win_size_restore(&winsizes); + skip_win_fix_cursor = FALSE; } ga_clear(&winsizes); diff --git a/src/globals.h b/src/globals.h index 521832428a..568d3b3c82 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1737,3 +1737,8 @@ EXTERN int channel_need_redraw INIT(= FALSE); // While executing a regexp and set to OPTION_MAGIC_ON or OPTION_MAGIC_OFF this // overrules p_magic. Otherwise set to OPTION_MAGIC_NOT_SET. EXTERN optmagic_T magic_overruled INIT(= OPTION_MAGIC_NOT_SET); + +#ifdef FEAT_CMDWIN +// Skip win_fix_cursor() call for 'nosplitscroll' when cmdwin is closed. +EXTERN int skip_win_fix_cursor INIT(= FALSE); +#endif diff --git a/src/version.c b/src/version.c index 82a21df039..8b4efd7dba 100644 --- a/src/version.c +++ b/src/version.c @@ -703,6 +703,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 469, /**/ 468, /**/ diff --git a/src/window.c b/src/window.c index 6fefcac750..fc7b8df3b0 100644 --- a/src/window.c +++ b/src/window.c @@ -6410,6 +6410,10 @@ win_fix_cursor(int normal) if (wp->w_buffer->b_ml.ml_line_count < wp->w_height) return; +#ifdef FEAT_CMDWIN + if (skip_win_fix_cursor) + return; +#endif so = MIN(wp->w_height / 2, so); // Check if cursor position is above topline or below botline.