Patch 9.0.0466
Problem: Virtual text wrong after adding line break after line.
Solution: Pass an "eol" flag to where text properties are adjusted.
(closes #11131)
Files: src/change.c, src/textprop.c, src/proto/
textprop.pro,
src/testdir/test_textprop.vim,
src/testdir/dumps/Test_prop_below_split_line_1.dump
*** ../vim-9.0.0465/src/change.c 2022-09-02 17:12:03.668881359 +0100
--- src/change.c 2022-09-14 21:59:33.083561796 +0100
***************
*** 1404,1415 ****
--- 1404,1422 ----
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,2139 ****
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);
#endif
}
else
--- 2140,2146 ----
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, at_eol);
#endif
}
else
*** ../vim-9.0.0465/src/textprop.c 2022-09-14 12:06:45.783430773 +0100
--- src/textprop.c 2022-09-14 22:00:42.731408284 +0100
***************
*** 2232,2244 ****
* "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.
*/
void
adjust_props_for_split(
! linenr_T lnum_props,
! linenr_T lnum_top,
! int kept,
! int deleted)
{
char_u *props;
int count;
--- 2232,2246 ----
* "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,
! int at_eol)
{
char_u *props;
int count;
***************
*** 2276,2284 ****
// 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;
// when a prop has text it is never copied
if (prop.tp_id < 0 && cont_next)
cont_prev = FALSE;
--- 2278,2293 ----
// 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;
! 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,2303 ****
// 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)
{
textprop_T *p = ((textprop_T *)nextprop.ga_data) + nextprop.ga_len;
--- 2306,2312 ----
// Only add the property to the next line if the length is bigger than
// zero.
! if (cont_next && ga_grow(&nextprop, 1) == OK)
{
textprop_T *p = ((textprop_T *)nextprop.ga_data) + nextprop.ga_len;
*** ../vim-9.0.0465/src/proto/
textprop.pro 2022-09-12 17:50:42.782378262 +0100
--- src/proto/
textprop.pro 2022-09-14 21:59:16.187599320 +0100
***************
*** 22,27 ****
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 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 : */
--- 22,27 ----
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, 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 : */
*** ../vim-9.0.0465/src/testdir/test_textprop.vim 2022-09-14 16:09:53.344308323 +0100
--- src/testdir/test_textprop.vim 2022-09-14 22:09:26.310297019 +0100
***************
*** 2908,2913 ****
--- 2908,2936 ----
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\<CR>xx")
+ call VerifyScreenDump(buf, 'Test_prop_below_split_line_1', {})
+
+ call term_sendkeys(buf, "\<Esc>")
+ call StopVimInTerminal(buf)
+ endfunc
+
func Test_props_with_text_override()
CheckRunVimInTerminal
***************
*** 2920,2926 ****
hi CursorLine cterm=underline ctermbg=lightgrey
set cursorline
END
! call writefile(lines, 'XscriptPropsOverride')
let buf = RunVimInTerminal('-S XscriptPropsOverride', #{rows: 6, cols: 60})
call VerifyScreenDump(buf, 'Test_prop_with_text_override_1', {})
--- 2943,2949 ----
hi CursorLine cterm=underline ctermbg=lightgrey
set cursorline
END
! call writefile(lines, 'XscriptPropsOverride', 'D')
let buf = RunVimInTerminal('-S XscriptPropsOverride', #{rows: 6, cols: 60})
call VerifyScreenDump(buf, 'Test_prop_with_text_override_1', {})
***************
*** 2929,2935 ****
call VerifyScreenDump(buf, 'Test_prop_with_text_override_2', {})
call StopVimInTerminal(buf)
- call delete('XscriptPropsOverride')
endfunc
func Test_props_with_text_CursorMoved()
--- 2952,2957 ----
*** ../vim-9.0.0465/src/testdir/dumps/Test_prop_below_split_line_1.dump 2022-09-14 22:12:20.225938090 +0100
--- src/testdir/dumps/Test_prop_below_split_line_1.dump 2022-09-14 22:09:35.734277489 +0100
***************
*** 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|
*** ../vim-9.0.0465/src/version.c 2022-09-14 22:11:47.674005040 +0100
--- src/version.c 2022-09-14 21:55:19.636139508 +0100
***************
*** 705,706 ****
--- 705,708 ----
{ /* Add new patch number below this line */
+ /**/
+ 466,
/**/
--
hundred-and-one symptoms of being an internet addict:
74. Your most erotic dreams are about cybersex
/// Bram Moolenaar -- Br...@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 ///