mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
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)
This commit is contained in:
parent
e697d48890
commit
ebd0e8bb85
@ -1404,12 +1404,19 @@ open_line(
|
|||||||
int vreplace_mode;
|
int vreplace_mode;
|
||||||
int did_append; // appended a new line
|
int did_append; // appended a new line
|
||||||
int saved_pi = curbuf->b_p_pi; // copy of preserveindent setting
|
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
|
// make a copy of the current line so we can mess with it
|
||||||
saved_line = vim_strsave(ml_get_curline());
|
saved_line = vim_strsave(ml_get_curline());
|
||||||
if (saved_line == NULL) // out of memory!
|
if (saved_line == NULL) // out of memory!
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
#ifdef FEAT_PROP_POPUP
|
||||||
|
at_eol = curwin->w_cursor.col >= (int)STRLEN(saved_line);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (State & VREPLACE_FLAG)
|
if (State & VREPLACE_FLAG)
|
||||||
{
|
{
|
||||||
// With MODE_VREPLACE we make a copy of the next line, which we will be
|
// 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)
|
if ((State & MODE_INSERT) && (State & VREPLACE_FLAG) == 0)
|
||||||
// Properties after the split move to the next line.
|
// Properties after the split move to the next line.
|
||||||
adjust_props_for_split(curwin->w_cursor.lnum, curwin->w_cursor.lnum,
|
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
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -22,6 +22,6 @@ void f_prop_type_list(typval_T *argvars, typval_T *rettv);
|
|||||||
void clear_global_prop_types(void);
|
void clear_global_prop_types(void);
|
||||||
void clear_buf_prop_types(buf_T *buf);
|
void clear_buf_prop_types(buf_T *buf);
|
||||||
int adjust_prop_columns(linenr_T lnum, colnr_T col, int bytes_added, int flags);
|
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);
|
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: set ft=c : */
|
||||||
|
8
src/testdir/dumps/Test_prop_below_split_line_1.dump
Normal file
8
src/testdir/dumps/Test_prop_below_split_line_1.dump
Normal file
@ -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|
|
@ -2908,6 +2908,29 @@ func Test_prop_above_with_indent()
|
|||||||
call prop_type_delete('indented')
|
call prop_type_delete('indented')
|
||||||
endfunc
|
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()
|
func Test_props_with_text_override()
|
||||||
CheckRunVimInTerminal
|
CheckRunVimInTerminal
|
||||||
|
|
||||||
@ -2920,7 +2943,7 @@ func Test_props_with_text_override()
|
|||||||
hi CursorLine cterm=underline ctermbg=lightgrey
|
hi CursorLine cterm=underline ctermbg=lightgrey
|
||||||
set cursorline
|
set cursorline
|
||||||
END
|
END
|
||||||
call writefile(lines, 'XscriptPropsOverride')
|
call writefile(lines, 'XscriptPropsOverride', 'D')
|
||||||
let buf = RunVimInTerminal('-S XscriptPropsOverride', #{rows: 6, cols: 60})
|
let buf = RunVimInTerminal('-S XscriptPropsOverride', #{rows: 6, cols: 60})
|
||||||
call VerifyScreenDump(buf, 'Test_prop_with_text_override_1', {})
|
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 VerifyScreenDump(buf, 'Test_prop_with_text_override_2', {})
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
call delete('XscriptPropsOverride')
|
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_props_with_text_CursorMoved()
|
func Test_props_with_text_CursorMoved()
|
||||||
|
@ -2232,13 +2232,15 @@ adjust_prop_columns(
|
|||||||
* "lnum_top" is the top line.
|
* "lnum_top" is the top line.
|
||||||
* "kept" is the number of bytes kept in the first line, while
|
* "kept" is the number of bytes kept in the first line, while
|
||||||
* "deleted" is the number of bytes deleted.
|
* "deleted" is the number of bytes deleted.
|
||||||
|
* "at_eol" is true if the split is after the end of the line.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
adjust_props_for_split(
|
adjust_props_for_split(
|
||||||
linenr_T lnum_props,
|
linenr_T lnum_props,
|
||||||
linenr_T lnum_top,
|
linenr_T lnum_top,
|
||||||
int kept,
|
int kept,
|
||||||
int deleted)
|
int deleted,
|
||||||
|
int at_eol)
|
||||||
{
|
{
|
||||||
char_u *props;
|
char_u *props;
|
||||||
int count;
|
int count;
|
||||||
@ -2276,9 +2278,16 @@ adjust_props_for_split(
|
|||||||
// a text prop "above" behaves like it is on the first text column
|
// 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;
|
prop_col = (prop.tp_flags & TP_FLAG_ALIGN_ABOVE) ? 1 : prop.tp_col;
|
||||||
|
|
||||||
cont_prev = prop_col != MAXCOL && prop_col + !start_incl <= kept;
|
if (prop_col == MAXCOL)
|
||||||
cont_next = prop_col != MAXCOL
|
{
|
||||||
&& skipped <= prop_col + prop.tp_len - !end_incl;
|
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
|
// when a prop has text it is never copied
|
||||||
if (prop.tp_id < 0 && cont_next)
|
if (prop.tp_id < 0 && cont_next)
|
||||||
cont_prev = FALSE;
|
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
|
// Only add the property to the next line if the length is bigger than
|
||||||
// zero.
|
// 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;
|
textprop_T *p = ((textprop_T *)nextprop.ga_data) + nextprop.ga_len;
|
||||||
|
|
||||||
|
@ -703,6 +703,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
466,
|
||||||
/**/
|
/**/
|
||||||
465,
|
465,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user