From bffba7f7042f6082e75b42484b15f66087b01941 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 20 Sep 2019 17:00:17 +0200 Subject: [PATCH] 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) --- runtime/doc/options.txt | 6 ++-- src/drawline.c | 4 ++- src/testdir/test_display.vim | 55 ++++++++++++++++++++++++++++++++++++ src/testdir/view_util.vim | 1 + src/version.c | 2 ++ 5 files changed, 64 insertions(+), 4 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 9f3d1dae67382c..1dd74919bc35d3 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -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. diff --git a/src/drawline.c b/src/drawline.c index 39ec5ed4060263..5916458be3438c 100644 --- a/src/drawline.c +++ b/src/drawline.c @@ -2482,7 +2482,9 @@ win_line( // special character (via 'listchars' option "precedes:". 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 diff --git a/src/testdir/test_display.vim b/src/testdir/test_display.vim index 6856759ecc6e9c..f500dc7891e8e0 100644 --- a/src/testdir/test_display.vim +++ b/src/testdir/test_display.vim @@ -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 = [ + \ "