Skip to content

Commit

Permalink
patch 8.1.2060: "precedes" in 'listchars' not used properly
Browse files Browse the repository at this point in the history
Problem:    "precedes" in 'listchars' not used properly.
Solution:   Correctly handle the "precedes" char in list mode for long lines.
            (Christian Brabandt, closes vim#4953)
  • Loading branch information
brammool committed Sep 20, 2019
1 parent 589edb3 commit bffba7f
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 4 deletions.
6 changes: 3 additions & 3 deletions runtime/doc/options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4842,9 +4842,9 @@ A jump table for the options with a short description can be found at |Q_op|.
off and the line continues beyond the right of the
screen.
*lcs-precedes*
precedes:c Character to show in the first column, when 'wrap'
is off and there is text preceding the character
visible in the first column.
precedes:c Character to show in the first visible column of the
physical line, when there is text preceding the
character visible in the first column.
*lcs-conceal*
conceal:c Character to show in place of concealed text, when
'conceallevel' is set to 1.
Expand Down
4 changes: 3 additions & 1 deletion src/drawline.c
Original file line number Diff line number Diff line change
Expand Up @@ -2482,7 +2482,9 @@ win_line(
// special character (via 'listchars' option "precedes:<char>".
if (lcs_prec_todo != NUL
&& wp->w_p_list
&& (wp->w_p_wrap ? wp->w_skipcol > 0 : wp->w_leftcol > 0)
&& (wp->w_p_wrap ?
(wp->w_skipcol > 0 && row == 0) :
wp->w_leftcol > 0)
#ifdef FEAT_DIFF
&& filler_todo <= 0
#endif
Expand Down
55 changes: 55 additions & 0 deletions src/testdir/test_display.vim
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,58 @@ func Test_scroll_without_region()
call StopVimInTerminal(buf)
call delete('Xtestscroll')
endfunc

func Test_display_listchars_precedes()
call NewWindow(10, 10)
" Need a physical line that wraps over the complete
" window size
call append(0, repeat('aaa aaa aa ', 10))
call append(1, repeat(['bbb bbb bbb bbb'], 2))
" remove blank trailing line
$d
set list nowrap
call cursor(1, 1)
" move to end of line and scroll 2 characters back
norm! $2zh
let lines=ScreenLines([1,4], winwidth(0)+1)
let expect = [
\ " aaa aa $ |",
\ "$ |",
\ "$ |",
\ "~ |",
\ ]
call assert_equal(expect, lines)
set list listchars+=precedes:< nowrap
call cursor(1, 1)
" move to end of line and scroll 2 characters back
norm! $2zh
let lines = ScreenLines([1,4], winwidth(0)+1)
let expect = [
\ "<aaa aa $ |",
\ "< |",
\ "< |",
\ "~ |",
\ ]
call assert_equal(expect, lines)
set wrap
call cursor(1, 1)
" the complete line should be displayed in the window
norm! $

let lines = ScreenLines([1,10], winwidth(0)+1)
let expect = [
\ "<aaa aaa a|",
\ "a aaa aaa |",
\ "aa aaa aaa|",
\ " aa aaa aa|",
\ "a aa aaa a|",
\ "aa aa aaa |",
\ "aaa aa aaa|",
\ " aaa aa aa|",
\ "a aaa aa a|",
\ "aa aaa aa |",
\ ]
call assert_equal(expect, lines)
set list& listchars& wrap&
bw!
endfunc
1 change: 1 addition & 0 deletions src/testdir/view_util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ endfunction
function! NewWindow(height, width) abort
exe a:height . 'new'
exe a:width . 'vsp'
set winfixwidth winfixheight
redraw!
endfunction

Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2060,
/**/
2059,
/**/
Expand Down

0 comments on commit bffba7f

Please sign in to comment.