mirror of
https://github.com/vim/vim.git
synced 2025-09-28 04:24:06 -04:00
patch 9.0.1800: Cursor position still wrong with 'showbreak' and virtual text
Problem: Cursor position still wrong with 'showbreak' and virtual text after last character or 'listchars' "eol". Solution: Remove unnecessary w_wcol adjustment in curs_columns(). Also fix first char of virtual text not shown at the start of a screen line. closes: #12478 closes: #12532 closes: #12904 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
This commit is contained in:
committed by
Christian Brabandt
parent
9a6cf34a1e
commit
6a3897232a
@@ -1358,13 +1358,13 @@ win_lbr_chartabsize(
|
|||||||
head_mid += get_breakindent_win(wp, line);
|
head_mid += get_breakindent_win(wp, line);
|
||||||
if (head_mid > 0 && wcol + size > wp->w_width)
|
if (head_mid > 0 && wcol + size > wp->w_width)
|
||||||
{
|
{
|
||||||
// calculate effective window width
|
// Calculate effective window width.
|
||||||
int prev_rem = wp->w_width - wcol;
|
int prev_rem = wp->w_width - wcol;
|
||||||
int width = width2 - head_mid;
|
int width = width2 - head_mid;
|
||||||
|
|
||||||
if (width <= 0)
|
if (width <= 0)
|
||||||
width = 1;
|
width = 1;
|
||||||
// divide "size - prev_width" by "width", rounding up
|
// Divide "size - prev_rem" by "width", rounding up.
|
||||||
int cnt = (size - prev_rem + width - 1) / width;
|
int cnt = (size - prev_rem + width - 1) / width;
|
||||||
added += cnt * head_mid;
|
added += cnt * head_mid;
|
||||||
|
|
||||||
|
@@ -3733,7 +3733,11 @@ win_line(
|
|||||||
&& (*ptr != NUL
|
&& (*ptr != NUL
|
||||||
|| lcs_eol_one > 0
|
|| lcs_eol_one > 0
|
||||||
|| (wlv.n_extra > 0 && (wlv.c_extra != NUL
|
|| (wlv.n_extra > 0 && (wlv.c_extra != NUL
|
||||||
|| *wlv.p_extra != NUL))))
|
|| *wlv.p_extra != NUL))
|
||||||
|
#ifdef FEAT_PROP_POPUP
|
||||||
|
|| text_prop_next < text_prop_count
|
||||||
|
#endif
|
||||||
|
))
|
||||||
{
|
{
|
||||||
c = wp->w_lcs_chars.ext;
|
c = wp->w_lcs_chars.ext;
|
||||||
wlv.char_attr = hl_combine_attr(wlv.win_attr, HL_ATTR(HLF_AT));
|
wlv.char_attr = hl_combine_attr(wlv.win_attr, HL_ATTR(HLF_AT));
|
||||||
@@ -4014,6 +4018,7 @@ win_line(
|
|||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_PROP_POPUP
|
#ifdef FEAT_PROP_POPUP
|
||||||
|| text_prop_above || text_prop_follows
|
|| text_prop_above || text_prop_follows
|
||||||
|
|| text_prop_next < text_prop_count
|
||||||
#endif
|
#endif
|
||||||
|| (wp->w_p_list && wp->w_lcs_chars.eol != NUL
|
|| (wp->w_p_list && wp->w_lcs_chars.eol != NUL
|
||||||
&& wlv.p_extra != at_end_str)
|
&& wlv.p_extra != at_end_str)
|
||||||
|
11
src/move.c
11
src/move.c
@@ -1205,17 +1205,6 @@ curs_columns(
|
|||||||
n = (curwin->w_wcol - curwin->w_width) / width2 + 1;
|
n = (curwin->w_wcol - curwin->w_width) / width2 + 1;
|
||||||
curwin->w_wcol -= n * width2;
|
curwin->w_wcol -= n * width2;
|
||||||
curwin->w_wrow += n;
|
curwin->w_wrow += n;
|
||||||
|
|
||||||
#ifdef FEAT_LINEBREAK
|
|
||||||
// When cursor wraps to first char of next line in Insert
|
|
||||||
// mode, the 'showbreak' string isn't shown, backup to first
|
|
||||||
// column
|
|
||||||
char_u *sbr = get_showbreak_value(curwin);
|
|
||||||
if (*sbr && *ml_get_cursor() == NUL
|
|
||||||
&& curwin->w_wcol
|
|
||||||
== (curwin->w_width - width2) + vim_strsize(sbr))
|
|
||||||
curwin->w_wcol = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,6 @@
|
|||||||
|
| +0#0000e05#a8a8a8255@1|x+0#0000000#ffffff0@71|X
|
||||||
|
| +0#0000e05#a8a8a8255@1|++0#4040ff13#ffffff0>$| +0#0000000&@70
|
||||||
|
| +0#0000e05#a8a8a8255@1|s+0#0000000#ffffff0|e|c|o|n|d| |l|i|n|e|$+0#4040ff13&| +0#0000000&@60
|
||||||
|
|~+0#4040ff13&| @73
|
||||||
|
|~| @73
|
||||||
|
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@44|1|,|7|4| @9|A|l@1|
|
@@ -0,0 +1,3 @@
|
|||||||
|
|a+0&#ffffff0@19>a@28|!+0#4040ff13&
|
||||||
|
|~| @48
|
||||||
|
| +0#0000000&@31|1|,|2|1| @9|A|l@1|
|
@@ -0,0 +1,3 @@
|
|||||||
|
|a+0&#ffffff0@18>a@29|!+0#4040ff13&
|
||||||
|
|~| @48
|
||||||
|
| +0#0000000&@31|1|,|2|1| @9|A|l@1|
|
@@ -0,0 +1,3 @@
|
|||||||
|
|a+0&#ffffff0@17>a@30|!+0#4040ff13&
|
||||||
|
|~| @48
|
||||||
|
| +0#0000000&@31|1|,|2|1| @9|A|l@1|
|
@@ -0,0 +1,3 @@
|
|||||||
|
|a+0&#ffffff0@16>a@30|b+0#e000e06&|!+0#4040ff13&
|
||||||
|
|~| @48
|
||||||
|
| +0#0000000&@31|1|,|2|1| @9|A|l@1|
|
@@ -0,0 +1,3 @@
|
|||||||
|
|a+0&#ffffff0@15>a@30|b+0#e000e06&@2
|
||||||
|
|~+0#4040ff13&| @48
|
||||||
|
| +0#0000000&@31|1|,|2|1| @9|A|l@1|
|
@@ -0,0 +1,6 @@
|
|||||||
|
| +0&#ffffff0@1|1| |a@25
|
||||||
|
| @5|++0#4040ff13&>1+0#e000e06&|2|3|1|2|3|1|2|3|1|2|3|1|2|3|1|2|3|1|2|3|1|2
|
||||||
|
| +0#0000000&@5|++0#4040ff13&|3+0#e000e06&|1|2|3|1|2|3|1|2|3|1|2|3|1|2|3|1|2|3|1|2|3|1
|
||||||
|
| +0#0000000&@5|++0#4040ff13&|2+0#e000e06&|3|1|2|3|1|2|3|1|2|3|1|2|3|1|2|3|1|2|3|1|2|3
|
||||||
|
|~+0#4040ff13&| @28
|
||||||
|
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@17
|
@@ -0,0 +1,6 @@
|
|||||||
|
| +0&#ffffff0@1|1| |a@25
|
||||||
|
| @3|++0#4040ff13&>1+0#e000e06&|2|3|1|2|3|1|2|3|1|2|3|1|2|3|1|2|3|1|2|3|1|2|3|1
|
||||||
|
| +0#0000000&@3|++0#4040ff13&|2+0#e000e06&|3|1|2|3|1|2|3|1|2|3|1|2|3|1|2|3|1|2|3|1|2|3|1|2
|
||||||
|
| +0#0000000&@3|++0#4040ff13&|3+0#e000e06&|1|2|3|1|2|3|1|2|3|1|2|3|1|2|3|1|2|3| +0#0000000&@5
|
||||||
|
|~+0#4040ff13&| @28
|
||||||
|
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@17
|
@@ -898,7 +898,6 @@ func Test_cursor_position_with_showbreak()
|
|||||||
vim9script
|
vim9script
|
||||||
&signcolumn = 'yes'
|
&signcolumn = 'yes'
|
||||||
&showbreak = '++'
|
&showbreak = '++'
|
||||||
&breakindent = true
|
|
||||||
&breakindentopt = 'shift:2'
|
&breakindentopt = 'shift:2'
|
||||||
var leftcol: number = win_getid()->getwininfo()->get(0, {})->get('textoff')
|
var leftcol: number = win_getid()->getwininfo()->get(0, {})->get('textoff')
|
||||||
repeat('x', &columns - leftcol - 1)->setline(1)
|
repeat('x', &columns - leftcol - 1)->setline(1)
|
||||||
@@ -912,9 +911,14 @@ func Test_cursor_position_with_showbreak()
|
|||||||
" No line wraps, so changing 'showbreak' should lead to the same screen.
|
" No line wraps, so changing 'showbreak' should lead to the same screen.
|
||||||
call term_sendkeys(buf, "\<C-\>\<C-O>:setlocal showbreak=+\<CR>")
|
call term_sendkeys(buf, "\<C-\>\<C-O>:setlocal showbreak=+\<CR>")
|
||||||
call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak_1', {})
|
call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak_1', {})
|
||||||
|
" No line wraps, so setting 'breakindent' should lead to the same screen.
|
||||||
|
call term_sendkeys(buf, "\<C-\>\<C-O>:setlocal breakindent\<CR>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak_1', {})
|
||||||
" The first line now wraps because of "eol" in 'listchars'.
|
" The first line now wraps because of "eol" in 'listchars'.
|
||||||
call term_sendkeys(buf, "\<C-\>\<C-O>:setlocal list\<CR>")
|
call term_sendkeys(buf, "\<C-\>\<C-O>:setlocal list\<CR>")
|
||||||
call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak_2', {})
|
call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak_2', {})
|
||||||
|
call term_sendkeys(buf, "\<C-\>\<C-O>:setlocal nobreakindent\<CR>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_cursor_position_with_showbreak_3', {})
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
endfunc
|
||||||
|
@@ -2686,11 +2686,11 @@ func Run_test_prop_inserts_text_showbreak(cmd)
|
|||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
highlight! link LineNr Normal
|
highlight! link LineNr Normal
|
||||||
|
setlocal number showbreak=+ breakindent breakindentopt=shift:2
|
||||||
|
setlocal scrolloff=0 smoothscroll
|
||||||
call setline(1, repeat('a', 28))
|
call setline(1, repeat('a', 28))
|
||||||
call prop_type_add('theprop', #{highlight: 'Special'})
|
call prop_type_add('theprop', #{highlight: 'Special'})
|
||||||
call prop_add(1, 28, #{type: 'theprop', text: repeat('123', 23), text_wrap: 'wrap'})
|
call prop_add(1, 28, #{type: 'theprop', text: repeat('123', 23), text_wrap: 'wrap'})
|
||||||
setlocal number showbreak=+ breakindent breakindentopt=shift:2
|
|
||||||
setlocal scrolloff=0 smoothscroll
|
|
||||||
normal! $
|
normal! $
|
||||||
END
|
END
|
||||||
let lines = insert(lines, a:cmd)
|
let lines = insert(lines, a:cmd)
|
||||||
@@ -2740,6 +2740,10 @@ func Run_test_prop_inserts_text_showbreak(cmd)
|
|||||||
call VerifyScreenDump(buf, 'Test_prop_inserts_text_showbreak_21', {})
|
call VerifyScreenDump(buf, 'Test_prop_inserts_text_showbreak_21', {})
|
||||||
call term_sendkeys(buf, "zbx")
|
call term_sendkeys(buf, "zbx")
|
||||||
call VerifyScreenDump(buf, 'Test_prop_inserts_text_showbreak_22', {})
|
call VerifyScreenDump(buf, 'Test_prop_inserts_text_showbreak_22', {})
|
||||||
|
call term_sendkeys(buf, "26ia\<Esc>a")
|
||||||
|
call VerifyScreenDump(buf, 'Test_prop_inserts_text_showbreak_23', {})
|
||||||
|
call term_sendkeys(buf, "\<C-\>\<C-O>:setlocal breakindentopt=\<CR>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_prop_inserts_text_showbreak_24', {})
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
endfunc
|
||||||
@@ -2754,10 +2758,10 @@ func Test_prop_before_tab_skipcol()
|
|||||||
CheckRunVimInTerminal
|
CheckRunVimInTerminal
|
||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
|
setlocal list listchars=tab:<-> scrolloff=0 smoothscroll
|
||||||
call setline(1, repeat("\t", 4) .. 'a')
|
call setline(1, repeat("\t", 4) .. 'a')
|
||||||
call prop_type_add('theprop', #{highlight: 'Special'})
|
call prop_type_add('theprop', #{highlight: 'Special'})
|
||||||
call prop_add(1, 4, #{type: 'theprop', text: repeat('12', 32), text_wrap: 'wrap'})
|
call prop_add(1, 4, #{type: 'theprop', text: repeat('12', 32), text_wrap: 'wrap'})
|
||||||
setlocal list listchars=tab:<-> scrolloff=0 smoothscroll
|
|
||||||
normal! $
|
normal! $
|
||||||
END
|
END
|
||||||
call writefile(lines, 'XscriptPropsBeforeTabSkipcol', 'D')
|
call writefile(lines, 'XscriptPropsBeforeTabSkipcol', 'D')
|
||||||
@@ -2787,6 +2791,31 @@ func Test_prop_before_tab_skipcol()
|
|||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_prop_inserts_text_lcs_extends()
|
||||||
|
CheckRunVimInTerminal
|
||||||
|
|
||||||
|
let lines =<< trim END
|
||||||
|
setlocal nowrap list listchars=extends:!
|
||||||
|
call setline(1, repeat('a', &columns + 1))
|
||||||
|
call prop_type_add('theprop', #{highlight: 'Special'})
|
||||||
|
call prop_add(1, &columns + 2, #{type: 'theprop', text: 'bbb'})
|
||||||
|
END
|
||||||
|
call writefile(lines, 'XscriptPropsListExtends', 'D')
|
||||||
|
let buf = RunVimInTerminal('-S XscriptPropsListExtends', #{rows: 3, cols: 50})
|
||||||
|
call term_sendkeys(buf, '20l')
|
||||||
|
call VerifyScreenDump(buf, 'Test_prop_inserts_text_lcs_extends_1', {})
|
||||||
|
call term_sendkeys(buf, 'zl')
|
||||||
|
call VerifyScreenDump(buf, 'Test_prop_inserts_text_lcs_extends_2', {})
|
||||||
|
call term_sendkeys(buf, 'zl')
|
||||||
|
call VerifyScreenDump(buf, 'Test_prop_inserts_text_lcs_extends_3', {})
|
||||||
|
call term_sendkeys(buf, 'zl')
|
||||||
|
call VerifyScreenDump(buf, 'Test_prop_inserts_text_lcs_extends_4', {})
|
||||||
|
call term_sendkeys(buf, 'zl')
|
||||||
|
call VerifyScreenDump(buf, 'Test_prop_inserts_text_lcs_extends_5', {})
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_prop_add_with_text_fails()
|
func Test_prop_add_with_text_fails()
|
||||||
call prop_type_add('failing', #{highlight: 'ErrorMsg'})
|
call prop_type_add('failing', #{highlight: 'ErrorMsg'})
|
||||||
call assert_fails("call prop_add(1, 0, #{type: 'failing', text: 'X', end_lnum: 1})", 'E1305:')
|
call assert_fails("call prop_add(1, 0, #{type: 'failing', text: 'X', end_lnum: 1})", 'E1305:')
|
||||||
|
@@ -699,6 +699,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 */
|
||||||
|
/**/
|
||||||
|
1800,
|
||||||
/**/
|
/**/
|
||||||
1799,
|
1799,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user