mirror of
https://github.com/neovim/neovim.git
synced 2025-09-23 03:28:33 +00:00
vim-patch:8.1.2060: "precedes" in 'listchars' not used properly
(Credit: Zach Wegner, https://github.com/neovim/neovim/pull/11034)
Problem: "precedes" in 'listchars' not used properly.
Solution: Correctly handle the "precedes" char in list mode for long lines.
bffba7f704
This commit is contained in:
@@ -3698,8 +3698,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
|
off and the line continues beyond the right of the
|
||||||
screen.
|
screen.
|
||||||
*lcs-precedes*
|
*lcs-precedes*
|
||||||
precedes:c Character to show in the first column, when there is
|
precedes:c Character to show in the first visible column of the
|
||||||
text preceding the character visible in the first column.
|
physical line, when there is text preceding the
|
||||||
|
character visible in the first column.
|
||||||
*lcs-conceal*
|
*lcs-conceal*
|
||||||
conceal:c Character to show in place of concealed text, when
|
conceal:c Character to show in place of concealed text, when
|
||||||
'conceallevel' is set to 1. A space when omitted.
|
'conceallevel' is set to 1. A space when omitted.
|
||||||
|
@@ -3756,11 +3756,9 @@ win_line (
|
|||||||
char_attr = hl_combine_attr(char_attr, extra_attr);
|
char_attr = hl_combine_attr(char_attr, extra_attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Handle the case where we are in column 0 but not on the first
|
||||||
* Handle the case where we are in column 0 but not on the first
|
// character of the line and the user wants us to show us a
|
||||||
* character of the line and the user wants us to show us a
|
// special character (via 'listchars' option "precedes:<char>".
|
||||||
* special character (via 'listchars' option "precedes:<char>".
|
|
||||||
*/
|
|
||||||
if (lcs_prec_todo != NUL
|
if (lcs_prec_todo != NUL
|
||||||
&& wp->w_p_list
|
&& wp->w_p_list
|
||||||
&& (wp->w_p_wrap ? (wp->w_skipcol > 0 && row == 0) : wp->w_leftcol > 0)
|
&& (wp->w_p_wrap ? (wp->w_skipcol > 0 && row == 0) : wp->w_leftcol > 0)
|
||||||
|
@@ -69,3 +69,58 @@ func! Test_display_foldtext_mbyte()
|
|||||||
set foldtext& fillchars& foldmethod& fdc&
|
set foldtext& fillchars& foldmethod& fdc&
|
||||||
bw!
|
bw!
|
||||||
endfunc
|
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
|
||||||
|
@@ -42,6 +42,7 @@ endfunction
|
|||||||
function! NewWindow(height, width) abort
|
function! NewWindow(height, width) abort
|
||||||
exe a:height . 'new'
|
exe a:height . 'new'
|
||||||
exe a:width . 'vsp'
|
exe a:width . 'vsp'
|
||||||
|
set winfixwidth winfixheight
|
||||||
redraw!
|
redraw!
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user