Skip to content

Commit 2362772

Browse files
zeertzjqchrisbra
authored andcommitted
patch 9.0.2187: Visual not drawn with 'breakindent' when line doesn't fit
Problem: Visual selection isn't drawn with 'breakindent' when the line doesn't fit in the window (Jaehwang Jung) Solution: Adjust wlv->fromcol also for 'breakindent' (zeertzjq) closes: #13767 closes: #13768 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 92feeaf commit 2362772

7 files changed

Lines changed: 55 additions & 0 deletions

src/drawline.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,12 @@ handle_breakindent(win_T *wp, winlinevars_T *wlv)
527527
if (wp->w_skipcol > 0 && wlv->startrow == 0
528528
&& wp->w_p_wrap && wp->w_briopt_sbr)
529529
wlv->need_showbreak = FALSE;
530+
531+
// Correct start of highlighted area for 'breakindent',
532+
if (wlv->fromcol >= wlv->vcol
533+
&& wlv->fromcol < wlv->vcol + wlv->n_extra)
534+
wlv->fromcol = wlv->vcol + wlv->n_extra;
535+
530536
// Correct end of highlighted area for 'breakindent',
531537
// required when 'linebreak' is also set.
532538
if (wlv->tocol == wlv->vcol)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
|<+0#4040ff13#ffffff0@2| +0#0000000&@4| +0&#e0e0e08|9|3| |9|4| |9|5| |9|6| |9|7| |9|8| |9@1> +0&#ffffff0@45
2+
|[+3&&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|2|9|1|-|3@1|0| @5|A|l@1
3+
| +0&&@74
4+
|~+0#4040ff13&| @73
5+
|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1
6+
|-+2&&@1| |V|I|S|U|A|L| |-@1| +0&&@51|2|9|1| @7
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
| +0&#ffffff0@7|++0#4040ff13&@2| +0#0000000#e0e0e08|9|0| |9|1| |9|2| |9|3| |9|4| |9|5| |9|6| |9|7| |9|8| |9@1> +0&#ffffff0@33
2+
|[+3&&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|2|9|1|-|3|4|2| @5|A|l@1
3+
| +0&&@74
4+
|~+0#4040ff13&| @73
5+
|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1
6+
|-+2&&@1| |V|I|S|U|A|L| |-@1| +0&&@51|2|9|1| @7
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
|++0#4040ff13#ffffff0@2| +0#0000000&@4| +0&#e0e0e08|9|3| |9|4| |9|5| |9|6| |9|7| |9|8| |9@1> +0&#ffffff0@45
2+
|[+3&&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|2|9|1|-|3@1|0| @5|A|l@1
3+
| +0&&@74
4+
|~+0#4040ff13&| @73
5+
|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1
6+
|-+2&&@1| |V|I|S|U|A|L| |-@1| +0&&@51|2|9|1| @7
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
|++0#4040ff13#ffffff0@8>+@65
2+
|[+3#0000000&|N|o| |N|a|m|e|]| |[|+|]| @43|1|,|2|9|1|-|3|1|0| @5|A|l@1
3+
| +0&&@74
4+
|~+0#4040ff13&| @73
5+
|[+1#0000000&|N|o| |N|a|m|e|]| @47|0|,|0|-|1| @9|A|l@1
6+
|-+2&&@1| |V|I|S|U|A|L| |-@1| +0&&@51|2|9|1| @7

src/testdir/test_breakindent.vim

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,29 @@ func Test_cursor_position_with_showbreak()
923923
call StopVimInTerminal(buf)
924924
endfunc
925925

926+
func Test_visual_starts_before_skipcol()
927+
CheckScreendump
928+
929+
let lines =<< trim END
930+
1new
931+
setlocal breakindent
932+
call setline(1, "\t" .. join(range(100)))
933+
END
934+
call writefile(lines, 'XvisualStartsBeforeSkipcol', 'D')
935+
let buf = RunVimInTerminal('-S XvisualStartsBeforeSkipcol', #{rows: 6})
936+
937+
call term_sendkeys(buf, "v$")
938+
call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_1', {})
939+
call term_sendkeys(buf, "\<Esc>:setlocal showbreak=+++\<CR>gv")
940+
call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_2', {})
941+
call term_sendkeys(buf, "\<Esc>:setlocal breakindentopt+=sbr\<CR>gv")
942+
call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_3', {})
943+
call term_sendkeys(buf, "\<Esc>:setlocal nobreakindent\<CR>gv")
944+
call VerifyScreenDump(buf, 'Test_visual_starts_before_skipcol_4', {})
945+
946+
call StopVimInTerminal(buf)
947+
endfunc
948+
926949
func Test_no_spurious_match()
927950
let s:input = printf('- y %s y %s', repeat('x', 50), repeat('x', 50))
928951
call s:test_windows('setl breakindent breakindentopt=list:-1 formatlistpat=^- hls')

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
2187,
707709
/**/
708710
2186,
709711
/**/

0 commit comments

Comments
 (0)