Skip to content

Commit bffba7f

Browse files
committed
patch 8.1.2060: "precedes" in 'listchars' not used properly
Problem: "precedes" in 'listchars' not used properly. Solution: Correctly handle the "precedes" char in list mode for long lines. (Christian Brabandt, closes #4953)
1 parent 589edb3 commit bffba7f

5 files changed

Lines changed: 64 additions & 4 deletions

File tree

runtime/doc/options.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4842,9 +4842,9 @@ A jump table for the options with a short description can be found at |Q_op|.
48424842
off and the line continues beyond the right of the
48434843
screen.
48444844
*lcs-precedes*
4845-
precedes:c Character to show in the first column, when 'wrap'
4846-
is off and there is text preceding the character
4847-
visible in the first column.
4845+
precedes:c Character to show in the first visible column of the
4846+
physical line, when there is text preceding the
4847+
character visible in the first column.
48484848
*lcs-conceal*
48494849
conceal:c Character to show in place of concealed text, when
48504850
'conceallevel' is set to 1.

src/drawline.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2482,7 +2482,9 @@ win_line(
24822482
// special character (via 'listchars' option "precedes:<char>".
24832483
if (lcs_prec_todo != NUL
24842484
&& wp->w_p_list
2485-
&& (wp->w_p_wrap ? wp->w_skipcol > 0 : wp->w_leftcol > 0)
2485+
&& (wp->w_p_wrap ?
2486+
(wp->w_skipcol > 0 && row == 0) :
2487+
wp->w_leftcol > 0)
24862488
#ifdef FEAT_DIFF
24872489
&& filler_todo <= 0
24882490
#endif

src/testdir/test_display.vim

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,58 @@ func Test_scroll_without_region()
103103
call StopVimInTerminal(buf)
104104
call delete('Xtestscroll')
105105
endfunc
106+
107+
func Test_display_listchars_precedes()
108+
call NewWindow(10, 10)
109+
" Need a physical line that wraps over the complete
110+
" window size
111+
call append(0, repeat('aaa aaa aa ', 10))
112+
call append(1, repeat(['bbb bbb bbb bbb'], 2))
113+
" remove blank trailing line
114+
$d
115+
set list nowrap
116+
call cursor(1, 1)
117+
" move to end of line and scroll 2 characters back
118+
norm! $2zh
119+
let lines=ScreenLines([1,4], winwidth(0)+1)
120+
let expect = [
121+
\ " aaa aa $ |",
122+
\ "$ |",
123+
\ "$ |",
124+
\ "~ |",
125+
\ ]
126+
call assert_equal(expect, lines)
127+
set list listchars+=precedes:< nowrap
128+
call cursor(1, 1)
129+
" move to end of line and scroll 2 characters back
130+
norm! $2zh
131+
let lines = ScreenLines([1,4], winwidth(0)+1)
132+
let expect = [
133+
\ "<aaa aa $ |",
134+
\ "< |",
135+
\ "< |",
136+
\ "~ |",
137+
\ ]
138+
call assert_equal(expect, lines)
139+
set wrap
140+
call cursor(1, 1)
141+
" the complete line should be displayed in the window
142+
norm! $
143+
144+
let lines = ScreenLines([1,10], winwidth(0)+1)
145+
let expect = [
146+
\ "<aaa aaa a|",
147+
\ "a aaa aaa |",
148+
\ "aa aaa aaa|",
149+
\ " aa aaa aa|",
150+
\ "a aa aaa a|",
151+
\ "aa aa aaa |",
152+
\ "aaa aa aaa|",
153+
\ " aaa aa aa|",
154+
\ "a aaa aa a|",
155+
\ "aa aaa aa |",
156+
\ ]
157+
call assert_equal(expect, lines)
158+
set list& listchars& wrap&
159+
bw!
160+
endfunc

src/testdir/view_util.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ endfunction
5454
function! NewWindow(height, width) abort
5555
exe a:height . 'new'
5656
exe a:width . 'vsp'
57+
set winfixwidth winfixheight
5758
redraw!
5859
endfunction
5960

src/version.c

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

758758
static int included_patches[] =
759759
{ /* Add new patch number below this line */
760+
/**/
761+
2060,
760762
/**/
761763
2059,
762764
/**/

0 commit comments

Comments
 (0)