mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
vim-patch:8.2.3295: 'cursorline' should not apply to 'breakindent' #15281
Problem: 'cursorline' should not apply to 'breakindent'.
Solution: Make 'cursorline' apply to 'breakindent' and 'showbreak'
consistently. (closes vim/vim#8684)
4f33bc20d7
This commit is contained in:
@@ -2381,13 +2381,12 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
|
|||||||
&& wp->w_p_culopt_flags != CULOPT_NBR) {
|
&& wp->w_p_culopt_flags != CULOPT_NBR) {
|
||||||
cul_screenline = (wp->w_p_wrap
|
cul_screenline = (wp->w_p_wrap
|
||||||
&& (wp->w_p_culopt_flags & CULOPT_SCRLINE));
|
&& (wp->w_p_culopt_flags & CULOPT_SCRLINE));
|
||||||
|
if (!cul_screenline) {
|
||||||
cul_attr = win_hl_attr(wp, HLF_CUL);
|
cul_attr = win_hl_attr(wp, HLF_CUL);
|
||||||
HlAttrs ae = syn_attr2entry(cul_attr);
|
HlAttrs ae = syn_attr2entry(cul_attr);
|
||||||
|
|
||||||
// We make a compromise here (#7383):
|
// We make a compromise here (#7383):
|
||||||
// * low-priority CursorLine if fg is not set
|
// * low-priority CursorLine if fg is not set
|
||||||
// * high-priority ("same as Vim" priority) CursorLine if fg is set
|
// * high-priority ("same as Vim" priority) CursorLine if fg is set
|
||||||
if (!cul_screenline) {
|
|
||||||
if (ae.rgb_fg_color == -1 && ae.cterm_fg_color == 0) {
|
if (ae.rgb_fg_color == -1 && ae.cterm_fg_color == 0) {
|
||||||
line_attr_lowprio = cul_attr;
|
line_attr_lowprio = cul_attr;
|
||||||
} else {
|
} else {
|
||||||
@@ -2399,7 +2398,6 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cul_attr = 0;
|
|
||||||
margin_columns_win(wp, &left_curline_col, &right_curline_col);
|
margin_columns_win(wp, &left_curline_col, &right_curline_col);
|
||||||
}
|
}
|
||||||
area_highlighting = true;
|
area_highlighting = true;
|
||||||
@@ -2700,6 +2698,12 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
|
|||||||
|
|
||||||
// Skip this quickly when working on the text.
|
// Skip this quickly when working on the text.
|
||||||
if (draw_state != WL_LINE) {
|
if (draw_state != WL_LINE) {
|
||||||
|
if (cul_screenline) {
|
||||||
|
cul_attr = 0;
|
||||||
|
line_attr = line_attr_save;
|
||||||
|
line_attr_lowprio = line_attr_lowprio_save;
|
||||||
|
}
|
||||||
|
|
||||||
if (draw_state == WL_CMDLINE - 1 && n_extra == 0) {
|
if (draw_state == WL_CMDLINE - 1 && n_extra == 0) {
|
||||||
draw_state = WL_CMDLINE;
|
draw_state = WL_CMDLINE;
|
||||||
if (cmdwin_type != 0 && wp == curwin) {
|
if (cmdwin_type != 0 && wp == curwin) {
|
||||||
@@ -2855,9 +2859,6 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
|
|||||||
|
|
||||||
if (diff_hlf != (hlf_T)0) {
|
if (diff_hlf != (hlf_T)0) {
|
||||||
char_attr = win_hl_attr(wp, diff_hlf);
|
char_attr = win_hl_attr(wp, diff_hlf);
|
||||||
if (cul_attr) {
|
|
||||||
char_attr = hl_combine_attr(char_attr, cul_attr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
p_extra = NULL;
|
p_extra = NULL;
|
||||||
c_extra = ' ';
|
c_extra = ' ';
|
||||||
@@ -2943,21 +2944,20 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cul_screenline) {
|
if (cul_screenline && draw_state == WL_LINE
|
||||||
if (draw_state == WL_LINE
|
|
||||||
&& vcol >= left_curline_col
|
&& vcol >= left_curline_col
|
||||||
&& vcol < right_curline_col) {
|
&& vcol < right_curline_col) {
|
||||||
cul_attr = win_hl_attr(wp, HLF_CUL);
|
cul_attr = win_hl_attr(wp, HLF_CUL);
|
||||||
HlAttrs ae = syn_attr2entry(cul_attr);
|
HlAttrs ae = syn_attr2entry(cul_attr);
|
||||||
if (ae.rgb_fg_color == -1 && ae.cterm_fg_color == 0) {
|
if (ae.rgb_fg_color == -1 && ae.cterm_fg_color == 0) {
|
||||||
line_attr_lowprio = cul_attr;
|
line_attr_lowprio = cul_attr;
|
||||||
|
} else {
|
||||||
|
if (!(State & INSERT) && bt_quickfix(wp->w_buffer)
|
||||||
|
&& qf_current_entry(wp) == lnum) {
|
||||||
|
line_attr = hl_combine_attr(cul_attr, line_attr);
|
||||||
} else {
|
} else {
|
||||||
line_attr = cul_attr;
|
line_attr = cul_attr;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
cul_attr = 0;
|
|
||||||
line_attr = line_attr_save;
|
|
||||||
line_attr_lowprio = line_attr_lowprio_save;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -192,7 +192,29 @@ func Test_cursorline_screenline()
|
|||||||
call term_sendkeys(buf, "gj")
|
call term_sendkeys(buf, "gj")
|
||||||
call term_wait(buf)
|
call term_wait(buf)
|
||||||
call VerifyScreenDump(buf, 'Test_'. filename. '_18', {})
|
call VerifyScreenDump(buf, 'Test_'. filename. '_18', {})
|
||||||
|
call term_sendkeys(buf, ":set breakindent& foldcolumn& signcolumn&\<cr>")
|
||||||
endif
|
endif
|
||||||
|
" showbreak should not be highlighted with CursorLine when 'number' is off
|
||||||
|
call term_sendkeys(buf, "gg0")
|
||||||
|
call term_sendkeys(buf, ":set list cursorlineopt=screenline listchars=space:-\<cr>")
|
||||||
|
call term_sendkeys(buf, ":set nonumber\<cr>")
|
||||||
|
call VerifyScreenDump(buf, 'Test_'. filename. '_19', {})
|
||||||
|
call term_sendkeys(buf, "fagj")
|
||||||
|
call term_wait(buf)
|
||||||
|
call VerifyScreenDump(buf, 'Test_'. filename. '_20', {})
|
||||||
|
call term_sendkeys(buf, "gj")
|
||||||
|
call term_wait(buf)
|
||||||
|
call VerifyScreenDump(buf, 'Test_'. filename. '_21', {})
|
||||||
|
call term_sendkeys(buf, "gj")
|
||||||
|
call term_wait(buf)
|
||||||
|
call VerifyScreenDump(buf, 'Test_'. filename. '_22', {})
|
||||||
|
call term_sendkeys(buf, "gj")
|
||||||
|
call term_wait(buf)
|
||||||
|
call VerifyScreenDump(buf, 'Test_'. filename. '_23', {})
|
||||||
|
call term_sendkeys(buf, "gj")
|
||||||
|
call term_wait(buf)
|
||||||
|
call VerifyScreenDump(buf, 'Test_'. filename. '_24', {})
|
||||||
|
call term_sendkeys(buf, ":set list& cursorlineopt& listchars&\<cr>")
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
call delete(filename)
|
call delete(filename)
|
||||||
|
@@ -990,6 +990,37 @@ func Test_diff_with_cursorline()
|
|||||||
call delete('Xtest_diff_cursorline')
|
call delete('Xtest_diff_cursorline')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_diff_with_cursorline_breakindent()
|
||||||
|
CheckScreendump
|
||||||
|
|
||||||
|
call writefile([
|
||||||
|
\ 'hi CursorLine ctermbg=red ctermfg=white',
|
||||||
|
\ 'set noequalalways wrap diffopt=followwrap cursorline breakindent',
|
||||||
|
\ '50vnew',
|
||||||
|
\ 'call setline(1, [" "," "," "," "])',
|
||||||
|
\ 'exe "norm 20Afoo\<Esc>j20Afoo\<Esc>j20Afoo\<Esc>j20Abar\<Esc>"',
|
||||||
|
\ 'vnew',
|
||||||
|
\ 'call setline(1, [" "," "," "," "])',
|
||||||
|
\ 'exe "norm 20Abee\<Esc>j20Afoo\<Esc>j20Afoo\<Esc>j20Abaz\<Esc>"',
|
||||||
|
\ 'windo diffthis',
|
||||||
|
\ '2wincmd w',
|
||||||
|
\ ], 'Xtest_diff_cursorline_breakindent')
|
||||||
|
let buf = RunVimInTerminal('-S Xtest_diff_cursorline_breakindent', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "gg0")
|
||||||
|
call VerifyScreenDump(buf, 'Test_diff_with_cul_bri_01', {})
|
||||||
|
call term_sendkeys(buf, "j")
|
||||||
|
call VerifyScreenDump(buf, 'Test_diff_with_cul_bri_02', {})
|
||||||
|
call term_sendkeys(buf, "j")
|
||||||
|
call VerifyScreenDump(buf, 'Test_diff_with_cul_bri_03', {})
|
||||||
|
call term_sendkeys(buf, "j")
|
||||||
|
call VerifyScreenDump(buf, 'Test_diff_with_cul_bri_04', {})
|
||||||
|
|
||||||
|
" clean up
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
call delete('Xtest_diff_cursorline_breakindent')
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_diff_with_syntax()
|
func Test_diff_with_syntax()
|
||||||
CheckScreendump
|
CheckScreendump
|
||||||
|
|
||||||
|
@@ -912,6 +912,97 @@ describe('CursorLine highlight', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("'cursorlineopt' screenline", function()
|
||||||
|
local screen = Screen.new(20,5)
|
||||||
|
screen:set_default_attr_ids({
|
||||||
|
[1] = {foreground = Screen.colors.Black, background = Screen.colors.White};
|
||||||
|
[2] = {foreground = Screen.colors.Yellow};
|
||||||
|
[3] = {foreground = Screen.colors.Red, background = Screen.colors.Green};
|
||||||
|
[4] = {foreground = Screen.colors.Green, background = Screen.colors.Red};
|
||||||
|
})
|
||||||
|
screen:attach()
|
||||||
|
|
||||||
|
feed_command('set wrap cursorline cursorlineopt=screenline')
|
||||||
|
feed_command('set showbreak=>>>')
|
||||||
|
feed_command('highlight clear NonText')
|
||||||
|
feed_command('highlight clear CursorLine')
|
||||||
|
feed_command('highlight NonText guifg=Yellow gui=NONE')
|
||||||
|
feed_command('highlight LineNr guifg=Red guibg=Green gui=NONE')
|
||||||
|
feed_command('highlight CursorLine guifg=Black guibg=White gui=NONE')
|
||||||
|
feed_command('highlight CursorLineNr guifg=Green guibg=Red gui=NONE')
|
||||||
|
|
||||||
|
feed('30iø<esc>o<esc>30ia<esc>')
|
||||||
|
|
||||||
|
-- CursorLine should not apply to 'showbreak' when 'cursorlineopt' contains "screenline"
|
||||||
|
screen:expect([[
|
||||||
|
øøøøøøøøøøøøøøøøøøøø|
|
||||||
|
{2:>>>}øøøøøøøøøø |
|
||||||
|
aaaaaaaaaaaaaaaaaaaa|
|
||||||
|
{2:>>>}{1:aaaaaaaaa^a }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
feed('gk')
|
||||||
|
screen:expect([[
|
||||||
|
øøøøøøøøøøøøøøøøøøøø|
|
||||||
|
{2:>>>}øøøøøøøøøø |
|
||||||
|
{1:aaaaaaaaaaaa^aaaaaaaa}|
|
||||||
|
{2:>>>}aaaaaaaaaa |
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
feed('k')
|
||||||
|
screen:expect([[
|
||||||
|
{1:øøøøøøøøøøøø^øøøøøøøø}|
|
||||||
|
{2:>>>}øøøøøøøøøø |
|
||||||
|
aaaaaaaaaaaaaaaaaaaa|
|
||||||
|
{2:>>>}aaaaaaaaaa |
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
-- CursorLineNr should not apply to line number when 'cursorlineopt' does not contain "number"
|
||||||
|
feed_command('set relativenumber numberwidth=2')
|
||||||
|
screen:expect([[
|
||||||
|
{3:0 }{1:øøøøøøøøøøøø^øøøøøø}|
|
||||||
|
{3: }{2:>>>}øøøøøøøøøøøø |
|
||||||
|
{3:1 }aaaaaaaaaaaaaaaaaa|
|
||||||
|
{3: }{2:>>>}aaaaaaaaaaaa |
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
|
||||||
|
-- CursorLineNr should apply to line number when 'cursorlineopt' contains "number"
|
||||||
|
feed_command('set cursorlineopt+=number')
|
||||||
|
screen:expect([[
|
||||||
|
{4:0 }{1:øøøøøøøøøøøø^øøøøøø}|
|
||||||
|
{3: }{2:>>>}øøøøøøøøøøøø |
|
||||||
|
{3:1 }aaaaaaaaaaaaaaaaaa|
|
||||||
|
{3: }{2:>>>}aaaaaaaaaaaa |
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
feed('gj')
|
||||||
|
screen:expect([[
|
||||||
|
{4:0 }øøøøøøøøøøøøøøøøøø|
|
||||||
|
{3: }{2:>>>}{1:øøøøøøøøø^øøø }|
|
||||||
|
{3:1 }aaaaaaaaaaaaaaaaaa|
|
||||||
|
{3: }{2:>>>}aaaaaaaaaaaa |
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
feed('gj')
|
||||||
|
screen:expect([[
|
||||||
|
{3:1 }øøøøøøøøøøøøøøøøøø|
|
||||||
|
{3: }{2:>>>}øøøøøøøøøøøø |
|
||||||
|
{4:0 }{1:aaaaaaaaaaaa^aaaaaa}|
|
||||||
|
{3: }{2:>>>}aaaaaaaaaaaa |
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
feed('gj')
|
||||||
|
screen:expect([[
|
||||||
|
{3:1 }øøøøøøøøøøøøøøøøøø|
|
||||||
|
{3: }{2:>>>}øøøøøøøøøøøø |
|
||||||
|
{4:0 }aaaaaaaaaaaaaaaaaa|
|
||||||
|
{3: }{2:>>>}{1:aaaaaaaaa^aaa }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
it('always updated. vim-patch:8.1.0849', function()
|
it('always updated. vim-patch:8.1.0849', function()
|
||||||
local screen = Screen.new(50,5)
|
local screen = Screen.new(50,5)
|
||||||
screen:set_default_attr_ids({
|
screen:set_default_attr_ids({
|
||||||
|
Reference in New Issue
Block a user