screen.c: Allow showbreak to override cursorline. (#13372)

I also added relevant tests.

Close #13369
This commit is contained in:
shade-of-noon
2020-11-25 11:47:03 -04:00
committed by GitHub
parent 104749440d
commit 2d5dd85eef
2 changed files with 54 additions and 3 deletions

View File

@@ -2836,9 +2836,9 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
* required when 'linebreak' is also set. */ * required when 'linebreak' is also set. */
if (tocol == vcol) if (tocol == vcol)
tocol += n_extra; tocol += n_extra;
/* combine 'showbreak' with 'cursorline' */ // Combine 'showbreak' with 'cursorline', prioritizing 'showbreak'.
if (wp->w_p_cul && lnum == wp->w_cursor.lnum) { if (wp->w_p_cul && lnum == wp->w_cursor.lnum) {
char_attr = hl_combine_attr(char_attr, win_hl_attr(wp, HLF_CUL)); char_attr = hl_combine_attr(win_hl_attr(wp, HLF_CUL), char_attr);
} }
} }
} }

View File

@@ -604,7 +604,7 @@ describe("'listchars' highlight", function()
]]) ]])
end) end)
it("'cursorline' and with 'listchar' option: space, eol, tab, and trail", function() it("'cursorline' and with 'listchars' option", function()
screen:set_default_attr_ids({ screen:set_default_attr_ids({
[1] = {background=Screen.colors.Grey90}, [1] = {background=Screen.colors.Grey90},
[2] = { [2] = {
@@ -861,6 +861,57 @@ describe('CursorLine highlight', function()
]]) ]])
end) end)
it("overridden by NonText in 'showbreak' characters", function()
local screen = Screen.new(20,5)
screen:set_default_attr_ids({
[1] = {foreground = Screen.colors.Yellow, background = Screen.colors.Blue};
[2] = {foreground = Screen.colors.Black, background = Screen.colors.White};
[3] = {foreground = Screen.colors.Yellow, background = Screen.colors.White};
[4] = {foreground = Screen.colors.Yellow};
})
screen:attach()
feed_command('set wrap cursorline')
feed_command('set showbreak=>>>')
feed_command('highlight clear NonText')
feed_command('highlight clear CursorLine')
feed_command('highlight NonText guifg=Yellow guibg=Blue gui=NONE')
feed_command('highlight CursorLine guifg=Black guibg=White gui=NONE')
feed('30iø<esc>o<esc>30ia<esc>')
screen:expect([[
øøøøøøøøøøøøøøøøøøøø|
{1:>>>}øøøøøøøøøø |
{2:aaaaaaaaaaaaaaaaaaaa}|
{1:>>>}{2:aaaaaaaaa^a }|
|
]])
feed('k')
screen:expect([[
{2:øøøøøøøøøøøøøøøøøøøø}|
{1:>>>}{2:øøøøøøøøø^ø }|
aaaaaaaaaaaaaaaaaaaa|
{1:>>>}aaaaaaaaaa |
|
]])
feed_command('highlight NonText guibg=NONE')
screen:expect([[
{2:øøøøøøøøøøøøøøøøøøøø}|
{3:>>>}{2:øøøøøøøøø^ø }|
aaaaaaaaaaaaaaaaaaaa|
{4:>>>}aaaaaaaaaa |
|
]])
feed_command('set nocursorline')
screen:expect([[
øøøøøøøøøøøøøøøøøøøø|
{4:>>>}øøøøøøøøø^ø |
aaaaaaaaaaaaaaaaaaaa|
{4:>>>}aaaaaaaaaa |
:set nocursorline |
]])
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({