2024-04-20 08:44:13 -07:00
|
|
|
local t = require('test.testutil')
|
|
|
|
local n = require('test.functional.testnvim')()
|
2018-06-17 04:31:13 -07:00
|
|
|
local Screen = require('test.functional.ui.screen')
|
2024-09-15 03:28:14 -07:00
|
|
|
local tt = require('test.functional.testterm')
|
2024-04-20 08:44:13 -07:00
|
|
|
|
|
|
|
local clear, insert = n.clear, n.insert
|
|
|
|
local command = n.command
|
|
|
|
local api = n.api
|
|
|
|
local testprg = n.testprg
|
2024-04-08 02:03:20 -07:00
|
|
|
local skip = t.skip
|
|
|
|
local is_os = t.is_os
|
2018-06-17 04:31:13 -07:00
|
|
|
|
|
|
|
describe('ext_hlstate detailed highlights', function()
|
|
|
|
local screen
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
clear()
|
|
|
|
command('syntax on')
|
2022-05-15 09:34:44 -07:00
|
|
|
command('hi VertSplit gui=reverse')
|
2024-11-11 14:15:19 -07:00
|
|
|
screen = Screen.new(40, 8, { ext_hlstate = true })
|
2018-06-17 04:31:13 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('work with combined UI and syntax highlights', function()
|
|
|
|
insert([[
|
|
|
|
these are some lines
|
|
|
|
with colorful text]])
|
2024-01-12 10:59:57 -07:00
|
|
|
api.nvim_buf_add_highlight(0, -1, 'String', 0, 10, 14)
|
|
|
|
api.nvim_buf_add_highlight(0, -1, 'Statement', 1, 5, -1)
|
2018-06-17 04:31:13 -07:00
|
|
|
command('/th co')
|
|
|
|
|
2024-02-20 09:25:57 -07:00
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
2018-06-17 04:31:13 -07:00
|
|
|
these are {1:some} lines |
|
|
|
|
^wi{2:th }{4:co}{3:lorful text} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{5:~ }|*5
|
2024-02-20 09:25:57 -07:00
|
|
|
{8:search hit BOTTOM, continuing at TOP}{6: }|
|
2018-06-17 04:31:13 -07:00
|
|
|
]],
|
2024-02-20 09:25:57 -07:00
|
|
|
attr_ids = {
|
2018-06-17 04:31:13 -07:00
|
|
|
[1] = {
|
2024-02-20 09:25:57 -07:00
|
|
|
{ foreground = Screen.colors.Magenta1 },
|
|
|
|
{ { kind = 'syntax', hi_name = 'Constant' } },
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
2018-06-17 04:31:13 -07:00
|
|
|
[2] = {
|
2024-02-20 09:25:57 -07:00
|
|
|
{ background = Screen.colors.Yellow1 },
|
|
|
|
{ { kind = 'ui', ui_name = 'Search', hi_name = 'Search' } },
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
2018-06-17 04:31:13 -07:00
|
|
|
[3] = {
|
2024-02-20 09:25:57 -07:00
|
|
|
{ foreground = Screen.colors.Brown, bold = true },
|
|
|
|
{ { kind = 'syntax', hi_name = 'Statement' } },
|
2018-06-17 04:31:13 -07:00
|
|
|
},
|
|
|
|
[4] = {
|
2024-02-20 09:25:57 -07:00
|
|
|
{ background = Screen.colors.Yellow1, bold = true, foreground = Screen.colors.Brown },
|
2018-06-17 04:31:13 -07:00
|
|
|
{ 3, 2 },
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
2018-06-17 04:31:13 -07:00
|
|
|
[5] = {
|
2024-02-20 09:25:57 -07:00
|
|
|
{ foreground = Screen.colors.Blue, bold = true },
|
|
|
|
{ { kind = 'ui', ui_name = 'EndOfBuffer', hi_name = 'NonText' } },
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
2024-02-20 09:25:57 -07:00
|
|
|
[6] = { {}, { { kind = 'ui', ui_name = 'MsgArea', hi_name = 'MsgArea' } } },
|
|
|
|
[7] = {
|
|
|
|
{ foreground = Screen.colors.Red1 },
|
|
|
|
{ { kind = 'syntax', hi_name = 'WarningMsg' } },
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
2024-02-20 09:25:57 -07:00
|
|
|
[8] = { { foreground = Screen.colors.Red1 }, { 6, 7 } },
|
|
|
|
},
|
|
|
|
}
|
2018-06-17 04:31:13 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
it('work with cleared UI highlights', function()
|
|
|
|
screen:set_default_attr_ids({
|
2022-05-15 09:34:44 -07:00
|
|
|
[1] = { {}, { { hi_name = 'Normal', ui_name = 'WinSeparator', kind = 'ui' } } },
|
2018-06-17 04:31:13 -07:00
|
|
|
[2] = {
|
|
|
|
{ bold = true, foreground = Screen.colors.Blue1 },
|
|
|
|
{ { hi_name = 'NonText', ui_name = 'EndOfBuffer', kind = 'ui' } },
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
2018-06-17 04:31:13 -07:00
|
|
|
[3] = {
|
|
|
|
{ bold = true, reverse = true },
|
|
|
|
{ { hi_name = 'StatusLine', ui_name = 'StatusLine', kind = 'ui' } },
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
2018-06-17 04:31:13 -07:00
|
|
|
[4] = {
|
|
|
|
{ reverse = true },
|
|
|
|
{ { hi_name = 'StatusLineNC', ui_name = 'StatusLineNC', kind = 'ui' } },
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
2018-06-17 04:31:13 -07:00
|
|
|
[5] = { {}, { { hi_name = 'StatusLine', ui_name = 'StatusLine', kind = 'ui' } } },
|
|
|
|
[6] = { {}, { { hi_name = 'StatusLineNC', ui_name = 'StatusLineNC', kind = 'ui' } } },
|
2019-09-01 02:25:00 -07:00
|
|
|
[7] = { {}, { { hi_name = 'MsgArea', ui_name = 'MsgArea', kind = 'ui' } } },
|
2018-06-17 04:31:13 -07:00
|
|
|
})
|
feat(highlight): update default color scheme
Problem: Default color scheme is suboptimal.
Solution: Start using new color scheme. Introduce new `vim` color scheme
for opt-in backward compatibility.
------
Main design ideas
- Be "Neovim branded".
- Be minimal for 256 colors with a bit more shades for true colors.
- Be accessible through high enough contrast ratios.
- Be suitable for dark and light backgrounds via exchange of dark and
light palettes.
------
Palettes
- Have dark and light variants. Implemented through exporeted
`NvimDark*` and `NvimLight*` hex colors.
- Palettes have 4 shades of grey for UI elements and 6 colors (red,
yellow, green, cyan, blue, magenta).
- Actual values are computed procedurally in Oklch color space based on
a handful of hyperparameters.
- Each color has a 256 colors variant with perceptually closest color.
------
Highlight groups
Use:
- Grey shades for general UI according to their design.
- Bold text for keywords (`Statement` highlight group). This is an
important choice to increase accessibility for people with color
deficiencies, as it doesn't rely on actual color.
- Green for strings, `DiffAdd` (as background), `DiagnosticOk`, and some
minor text UI elements.
- Cyan as main syntax color, i.e. for function usage (`Function`
highlight group), `DiffText`, `DiagnosticInfo`, and some minor text UI
elements.
- Red to generally mean high user attention, i.e. errors; in particular
for `ErrorMsg`, `DiffDelete`, `DiagnosticError`.
- Yellow very sparingly only with true colors to mean mild user
attention, i.e. warnings. That is, `DiagnosticWarn` and `WarningMsg`.
- Blue very sparingly only with true colors as `DiagnosticHint` and some
additional important syntax group (like `Identifier`).
- Magenta very carefully (if at all).
------
Notes
- To make tests work without relatively larege updates, each one is
prepended with an equivalent of the call `:colorscheme vim`.
Plus some tests which spawn new Neovim instances also now use 'vim'
color scheme.
In some cases tests are updated to fit new default color scheme.
2023-11-29 13:16:09 -07:00
|
|
|
command('hi clear WinSeparator')
|
2018-06-17 04:31:13 -07:00
|
|
|
command('vsplit')
|
|
|
|
|
|
|
|
screen:expect([[
|
|
|
|
^ {1:│} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{2:~ }{1:│}{2:~ }|*5
|
2018-06-17 04:31:13 -07:00
|
|
|
{3:[No Name] }{4:[No Name] }|
|
2019-09-01 02:25:00 -07:00
|
|
|
{7: }|
|
2018-06-17 04:31:13 -07:00
|
|
|
]])
|
|
|
|
|
|
|
|
command('hi clear StatusLine | hi clear StatuslineNC')
|
|
|
|
screen:expect([[
|
|
|
|
^ {1:│} |
|
2023-12-09 05:42:00 -07:00
|
|
|
{2:~ }{1:│}{2:~ }|*5
|
2018-06-17 04:31:13 -07:00
|
|
|
{5:[No Name] }{6:[No Name] }|
|
2019-09-01 02:25:00 -07:00
|
|
|
{7: }|
|
2018-06-17 04:31:13 -07:00
|
|
|
]])
|
|
|
|
|
|
|
|
-- redrawing is done even if visible highlights didn't change
|
|
|
|
command('wincmd w')
|
|
|
|
screen:expect([[
|
|
|
|
{1:│}^ |
|
2023-12-09 05:42:00 -07:00
|
|
|
{2:~ }{1:│}{2:~ }|*5
|
2018-06-17 04:31:13 -07:00
|
|
|
{6:[No Name] }{5:[No Name] }|
|
2019-09-01 02:25:00 -07:00
|
|
|
{7: }|
|
2018-06-17 04:31:13 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('work with window-local highlights', function()
|
|
|
|
screen:set_default_attr_ids({
|
|
|
|
[1] = {
|
|
|
|
{ foreground = Screen.colors.Brown },
|
|
|
|
{ { hi_name = 'LineNr', ui_name = 'LineNr', kind = 'ui' } },
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
2018-06-17 04:31:13 -07:00
|
|
|
[2] = {
|
|
|
|
{ bold = true, foreground = Screen.colors.Blue1 },
|
|
|
|
{ { hi_name = 'NonText', ui_name = 'EndOfBuffer', kind = 'ui' } },
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
2018-06-17 04:31:13 -07:00
|
|
|
[3] = {
|
|
|
|
{ bold = true, reverse = true },
|
|
|
|
{ { hi_name = 'StatusLine', ui_name = 'StatusLine', kind = 'ui' } },
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
2018-06-17 04:31:13 -07:00
|
|
|
[4] = {
|
|
|
|
{ reverse = true },
|
|
|
|
{ { hi_name = 'StatusLineNC', ui_name = 'StatusLineNC', kind = 'ui' } },
|
|
|
|
},
|
|
|
|
[5] = {
|
|
|
|
{ background = Screen.colors.Red, foreground = Screen.colors.Grey100 },
|
|
|
|
{ { hi_name = 'ErrorMsg', ui_name = 'LineNr', kind = 'ui' } },
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
2022-07-25 01:16:33 -07:00
|
|
|
[6] = {
|
|
|
|
{ bold = true, reverse = true },
|
|
|
|
{ { hi_name = 'Normal', ui_name = 'Normal', kind = 'ui' } },
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
2018-06-17 04:31:13 -07:00
|
|
|
[7] = { { foreground = Screen.colors.Brown, bold = true, reverse = true }, { 6, 1 } },
|
2022-07-25 01:16:33 -07:00
|
|
|
[8] = { { foreground = Screen.colors.Blue1, bold = true, reverse = true }, { 6, 14 } },
|
|
|
|
[9] = {
|
|
|
|
{ bold = true, foreground = Screen.colors.Brown },
|
|
|
|
{ { hi_name = 'NormalNC', ui_name = 'NormalNC', kind = 'ui' } },
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
2018-06-17 04:31:13 -07:00
|
|
|
[10] = { { bold = true, foreground = Screen.colors.Brown }, { 9, 1 } },
|
2022-07-25 01:16:33 -07:00
|
|
|
[11] = { { bold = true, foreground = Screen.colors.Blue1 }, { 9, 14 } },
|
2019-09-01 02:25:00 -07:00
|
|
|
[12] = { {}, { { hi_name = 'MsgArea', ui_name = 'MsgArea', kind = 'ui' } } },
|
2022-07-25 01:16:33 -07:00
|
|
|
[13] = {
|
|
|
|
{ background = Screen.colors.Red1, foreground = Screen.colors.Gray100 },
|
|
|
|
{ { ui_name = 'LineNr', kind = 'ui', hi_name = 'LineNr' } },
|
|
|
|
},
|
|
|
|
[14] = {
|
|
|
|
{ bold = true, foreground = Screen.colors.Blue },
|
|
|
|
{ { ui_name = 'EndOfBuffer', kind = 'ui', hi_name = 'EndOfBuffer' } },
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
2018-06-17 04:31:13 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
command('set number')
|
|
|
|
command('split')
|
|
|
|
-- NormalNC is not applied if not set, to avoid spurious redraws
|
|
|
|
screen:expect([[
|
|
|
|
{1: 1 }^ |
|
2023-12-09 05:42:00 -07:00
|
|
|
{2:~ }|*2
|
2018-06-17 04:31:13 -07:00
|
|
|
{3:[No Name] }|
|
|
|
|
{1: 1 } |
|
|
|
|
{2:~ }|
|
|
|
|
{4:[No Name] }|
|
2019-09-01 02:25:00 -07:00
|
|
|
{12: }|
|
2018-06-17 04:31:13 -07:00
|
|
|
]])
|
|
|
|
|
|
|
|
command('set winhl=LineNr:ErrorMsg')
|
2022-07-25 01:16:33 -07:00
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
{13: 1 }^ |
|
2023-12-09 05:42:00 -07:00
|
|
|
{14:~ }|*2
|
2018-06-17 04:31:13 -07:00
|
|
|
{3:[No Name] }|
|
|
|
|
{1: 1 } |
|
|
|
|
{2:~ }|
|
|
|
|
{4:[No Name] }|
|
2019-09-01 02:25:00 -07:00
|
|
|
{12: }|
|
2022-07-25 01:16:33 -07:00
|
|
|
]],
|
|
|
|
}
|
2018-06-17 04:31:13 -07:00
|
|
|
|
|
|
|
command('set winhl=Normal:MsgSeparator,NormalNC:Statement')
|
|
|
|
screen:expect([[
|
|
|
|
{7: 1 }{6:^ }|
|
2023-12-09 05:42:00 -07:00
|
|
|
{8:~ }|*2
|
2018-06-17 04:31:13 -07:00
|
|
|
{3:[No Name] }|
|
|
|
|
{1: 1 } |
|
|
|
|
{2:~ }|
|
|
|
|
{4:[No Name] }|
|
2019-09-01 02:25:00 -07:00
|
|
|
{12: }|
|
2018-06-17 04:31:13 -07:00
|
|
|
]])
|
|
|
|
|
|
|
|
command('wincmd w')
|
|
|
|
screen:expect([[
|
|
|
|
{10: 1 }{9: }|
|
2023-12-09 05:42:00 -07:00
|
|
|
{11:~ }|*2
|
2018-06-17 04:31:13 -07:00
|
|
|
{4:[No Name] }|
|
|
|
|
{1: 1 }^ |
|
|
|
|
{2:~ }|
|
|
|
|
{3:[No Name] }|
|
2019-09-01 02:25:00 -07:00
|
|
|
{12: }|
|
2018-06-17 04:31:13 -07:00
|
|
|
]])
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('work with :terminal', function()
|
2022-11-21 17:13:30 -07:00
|
|
|
skip(is_os('win'))
|
2022-02-19 03:11:05 -07:00
|
|
|
|
2018-06-17 04:31:13 -07:00
|
|
|
screen:set_default_attr_ids({
|
|
|
|
[1] = { {}, { { hi_name = 'TermCursorNC', ui_name = 'TermCursorNC', kind = 'ui' } } },
|
2019-11-02 02:57:07 -07:00
|
|
|
[2] = { { foreground = tonumber('0x00ccff'), fg_indexed = true }, { { kind = 'term' } } },
|
|
|
|
[3] = {
|
|
|
|
{ bold = true, foreground = tonumber('0x00ccff'), fg_indexed = true },
|
2024-01-02 18:09:18 -07:00
|
|
|
{
|
2019-11-02 02:57:07 -07:00
|
|
|
{ kind = 'term' },
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
|
|
|
},
|
2019-11-02 02:57:07 -07:00
|
|
|
[4] = { { foreground = tonumber('0x00ccff'), fg_indexed = true }, { 2, 1 } },
|
|
|
|
[5] = { { foreground = tonumber('0x40ffff'), fg_indexed = true }, { { kind = 'term' } } },
|
|
|
|
[6] = { { foreground = tonumber('0x40ffff'), fg_indexed = true }, { 5, 1 } },
|
2019-09-01 02:25:00 -07:00
|
|
|
[7] = { {}, { { hi_name = 'MsgArea', ui_name = 'MsgArea', kind = 'ui' } } },
|
2018-06-17 04:31:13 -07:00
|
|
|
})
|
2022-06-22 05:51:52 -07:00
|
|
|
command(("enew | call termopen(['%s'])"):format(testprg('tty-test')))
|
2018-06-17 04:31:13 -07:00
|
|
|
screen:expect([[
|
|
|
|
^tty ready |
|
|
|
|
{1: } |
|
2023-12-09 05:42:00 -07:00
|
|
|
|*5
|
2019-09-01 02:25:00 -07:00
|
|
|
{7: }|
|
2018-06-17 04:31:13 -07:00
|
|
|
]])
|
|
|
|
|
2024-04-08 02:03:20 -07:00
|
|
|
tt.feed_data('x ')
|
|
|
|
tt.set_fg(45)
|
|
|
|
tt.feed_data('y ')
|
|
|
|
tt.set_bold()
|
|
|
|
tt.feed_data('z\n')
|
2018-06-17 04:31:13 -07:00
|
|
|
-- TODO(bfredl): check if this distinction makes sense
|
2022-11-21 17:13:30 -07:00
|
|
|
if is_os('win') then
|
2018-06-17 04:31:13 -07:00
|
|
|
screen:expect([[
|
|
|
|
^tty ready |
|
|
|
|
x {5:y z} |
|
|
|
|
{1: } |
|
2023-12-09 05:42:00 -07:00
|
|
|
|*4
|
2019-09-01 02:25:00 -07:00
|
|
|
{7: }|
|
2018-06-17 04:31:13 -07:00
|
|
|
]])
|
|
|
|
else
|
|
|
|
screen:expect([[
|
|
|
|
^tty ready |
|
|
|
|
x {2:y }{3:z} |
|
|
|
|
{1: } |
|
2023-12-09 05:42:00 -07:00
|
|
|
|*4
|
2019-09-01 02:25:00 -07:00
|
|
|
{7: }|
|
2018-06-17 04:31:13 -07:00
|
|
|
]])
|
|
|
|
end
|
|
|
|
|
2024-04-08 02:03:20 -07:00
|
|
|
tt.feed_termcode('[A')
|
|
|
|
tt.feed_termcode('[2C')
|
2022-11-21 17:13:30 -07:00
|
|
|
if is_os('win') then
|
2018-06-17 04:31:13 -07:00
|
|
|
screen:expect([[
|
|
|
|
^tty ready |
|
|
|
|
x {6:y}{5: z} |
|
2023-12-09 05:42:00 -07:00
|
|
|
|*5
|
2019-09-01 02:25:00 -07:00
|
|
|
{7: }|
|
2018-06-17 04:31:13 -07:00
|
|
|
]])
|
|
|
|
else
|
|
|
|
screen:expect([[
|
|
|
|
^tty ready |
|
|
|
|
x {4:y}{2: }{3:z} |
|
2023-12-09 05:42:00 -07:00
|
|
|
|*5
|
2019-09-01 02:25:00 -07:00
|
|
|
{7: }|
|
2018-06-17 04:31:13 -07:00
|
|
|
]])
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('can use independent cterm and rgb colors', function()
|
|
|
|
-- tell test module to save all attributes (doesn't change nvim options)
|
2019-10-11 10:27:15 -07:00
|
|
|
screen:set_rgb_cterm(true)
|
2018-06-17 04:31:13 -07:00
|
|
|
|
|
|
|
screen:set_default_attr_ids({
|
|
|
|
[1] = {
|
|
|
|
{ bold = true, foreground = Screen.colors.Blue1 },
|
|
|
|
{ foreground = 12 },
|
|
|
|
{ { hi_name = 'NonText', ui_name = 'EndOfBuffer', kind = 'ui' } },
|
|
|
|
},
|
|
|
|
[2] = {
|
|
|
|
{ reverse = true, foreground = Screen.colors.Red },
|
|
|
|
{ foreground = 10, italic = true },
|
|
|
|
{ { hi_name = 'NonText', ui_name = 'EndOfBuffer', kind = 'ui' } },
|
2024-01-02 18:09:18 -07:00
|
|
|
},
|
2019-09-01 02:25:00 -07:00
|
|
|
[3] = { {}, {}, { { hi_name = 'MsgArea', ui_name = 'MsgArea', kind = 'ui' } } },
|
2018-06-17 04:31:13 -07:00
|
|
|
})
|
|
|
|
screen:expect([[
|
|
|
|
^ |
|
2023-12-09 05:42:00 -07:00
|
|
|
{1:~ }|*6
|
2019-09-01 02:25:00 -07:00
|
|
|
{3: }|
|
2018-06-17 04:31:13 -07:00
|
|
|
]])
|
|
|
|
|
|
|
|
command('hi NonText guifg=Red gui=reverse ctermfg=Green cterm=italic')
|
|
|
|
screen:expect([[
|
|
|
|
^ |
|
2023-12-09 05:42:00 -07:00
|
|
|
{2:~ }|*6
|
2019-09-01 02:25:00 -07:00
|
|
|
{3: }|
|
2018-06-17 04:31:13 -07:00
|
|
|
]])
|
|
|
|
end)
|
2024-02-05 05:38:42 -07:00
|
|
|
|
|
|
|
it('combines deleted extmark highlights', function()
|
|
|
|
insert([[
|
|
|
|
line1
|
|
|
|
line2
|
|
|
|
line3
|
|
|
|
line4
|
|
|
|
line5
|
|
|
|
line6]])
|
|
|
|
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
line1 |
|
|
|
|
line2 |
|
|
|
|
line3 |
|
|
|
|
line4 |
|
|
|
|
line5 |
|
|
|
|
line^6 |
|
|
|
|
{1:~ }|
|
|
|
|
{2: }|
|
|
|
|
]],
|
|
|
|
attr_ids = {
|
|
|
|
[1] = {
|
|
|
|
{ foreground = Screen.colors.Blue, bold = true },
|
|
|
|
{ { ui_name = 'EndOfBuffer', hi_name = 'NonText', kind = 'ui' } },
|
|
|
|
},
|
|
|
|
[2] = { {}, { { ui_name = 'MsgArea', hi_name = 'MsgArea', kind = 'ui' } } },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
local ns = api.nvim_create_namespace('test')
|
|
|
|
|
|
|
|
local add_indicator = function(line, col)
|
|
|
|
api.nvim_buf_set_extmark(0, ns, line, col, {
|
|
|
|
hl_mode = 'combine',
|
|
|
|
priority = 2,
|
|
|
|
right_gravity = false,
|
|
|
|
virt_text = { { '|', 'Delimiter' } },
|
|
|
|
virt_text_win_col = 0,
|
|
|
|
virt_text_pos = 'overlay',
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
add_indicator(1, 0)
|
|
|
|
add_indicator(2, 0)
|
|
|
|
add_indicator(3, 0)
|
|
|
|
add_indicator(4, 0)
|
|
|
|
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
line1 |
|
|
|
|
{1:|} line2 |
|
|
|
|
{1:|} line3 |
|
|
|
|
{1:|} line4 |
|
|
|
|
{1:|} line5 |
|
|
|
|
line^6 |
|
|
|
|
{2:~ }|
|
|
|
|
{3: }|
|
|
|
|
]],
|
|
|
|
attr_ids = {
|
|
|
|
[1] = {
|
|
|
|
{ foreground = Screen.colors.SlateBlue },
|
|
|
|
{ { hi_name = 'Special', kind = 'syntax' } },
|
|
|
|
},
|
|
|
|
[2] = {
|
|
|
|
{ bold = true, foreground = Screen.colors.Blue },
|
|
|
|
{ { ui_name = 'EndOfBuffer', kind = 'ui', hi_name = 'NonText' } },
|
|
|
|
},
|
|
|
|
[3] = { {}, { { ui_name = 'MsgArea', kind = 'ui', hi_name = 'MsgArea' } } },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-04-20 08:44:13 -07:00
|
|
|
n.feed('3ggV2jd')
|
2024-02-05 05:38:42 -07:00
|
|
|
--screen:redraw_debug()
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
line1 |
|
|
|
|
{1:|} line2 |
|
|
|
|
{2:^|}ine6 |
|
|
|
|
{3:~ }|*4
|
|
|
|
{4:3 fewer lines }|
|
|
|
|
]],
|
|
|
|
attr_ids = {
|
|
|
|
[1] = {
|
|
|
|
{ foreground = Screen.colors.SlateBlue },
|
|
|
|
{ { kind = 'syntax', hi_name = 'Special' } },
|
|
|
|
},
|
|
|
|
[2] = { { foreground = Screen.colors.SlateBlue }, { 1, 1, 1 } },
|
|
|
|
[3] = {
|
|
|
|
{ bold = true, foreground = Screen.colors.Blue },
|
|
|
|
{ { kind = 'ui', ui_name = 'EndOfBuffer', hi_name = 'NonText' } },
|
|
|
|
},
|
|
|
|
[4] = { {}, { { kind = 'ui', ui_name = 'MsgArea', hi_name = 'MsgArea' } } },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('removes deleted extmark highlights with invalidate', function()
|
|
|
|
insert([[
|
|
|
|
line1
|
|
|
|
line2
|
|
|
|
line3
|
|
|
|
line4
|
|
|
|
line5
|
|
|
|
line6]])
|
|
|
|
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
line1 |
|
|
|
|
line2 |
|
|
|
|
line3 |
|
|
|
|
line4 |
|
|
|
|
line5 |
|
|
|
|
line^6 |
|
|
|
|
{1:~ }|
|
|
|
|
{2: }|
|
|
|
|
]],
|
|
|
|
attr_ids = {
|
|
|
|
[1] = {
|
|
|
|
{ foreground = Screen.colors.Blue, bold = true },
|
|
|
|
{ { ui_name = 'EndOfBuffer', hi_name = 'NonText', kind = 'ui' } },
|
|
|
|
},
|
|
|
|
[2] = { {}, { { ui_name = 'MsgArea', hi_name = 'MsgArea', kind = 'ui' } } },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
local ns = api.nvim_create_namespace('test')
|
|
|
|
|
|
|
|
local add_indicator = function(line, col)
|
|
|
|
api.nvim_buf_set_extmark(0, ns, line, col, {
|
|
|
|
hl_mode = 'combine',
|
|
|
|
priority = 2,
|
|
|
|
right_gravity = false,
|
|
|
|
virt_text = { { '|', 'Delimiter' } },
|
|
|
|
virt_text_win_col = 0,
|
|
|
|
virt_text_pos = 'overlay',
|
|
|
|
invalidate = true,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
add_indicator(1, 0)
|
|
|
|
add_indicator(2, 0)
|
|
|
|
add_indicator(3, 0)
|
|
|
|
add_indicator(4, 0)
|
|
|
|
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
line1 |
|
|
|
|
{1:|} line2 |
|
|
|
|
{1:|} line3 |
|
|
|
|
{1:|} line4 |
|
|
|
|
{1:|} line5 |
|
|
|
|
line^6 |
|
|
|
|
{2:~ }|
|
|
|
|
{3: }|
|
|
|
|
]],
|
|
|
|
attr_ids = {
|
|
|
|
[1] = {
|
|
|
|
{ foreground = Screen.colors.SlateBlue },
|
|
|
|
{ { hi_name = 'Special', kind = 'syntax' } },
|
|
|
|
},
|
|
|
|
[2] = {
|
|
|
|
{ bold = true, foreground = Screen.colors.Blue },
|
|
|
|
{ { ui_name = 'EndOfBuffer', kind = 'ui', hi_name = 'NonText' } },
|
|
|
|
},
|
|
|
|
[3] = { {}, { { ui_name = 'MsgArea', kind = 'ui', hi_name = 'MsgArea' } } },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-04-20 08:44:13 -07:00
|
|
|
n.feed('3ggV2jd')
|
2024-02-05 05:38:42 -07:00
|
|
|
--screen:redraw_debug()
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
line1 |
|
|
|
|
{1:|} line2 |
|
|
|
|
^line6 |
|
|
|
|
{2:~ }|*4
|
|
|
|
{3:3 fewer lines }|
|
|
|
|
]],
|
|
|
|
attr_ids = {
|
|
|
|
[1] = {
|
|
|
|
{ foreground = Screen.colors.SlateBlue },
|
|
|
|
{ { kind = 'syntax', hi_name = 'Special' } },
|
|
|
|
},
|
|
|
|
[2] = {
|
|
|
|
{ foreground = Screen.colors.Blue, bold = true },
|
|
|
|
{ { kind = 'ui', ui_name = 'EndOfBuffer', hi_name = 'NonText' } },
|
|
|
|
},
|
|
|
|
[3] = { {}, { { kind = 'ui', ui_name = 'MsgArea', hi_name = 'MsgArea' } } },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
end)
|
|
|
|
|
|
|
|
it('does not hang when combining too many highlights', function()
|
|
|
|
local num_lines = 500
|
|
|
|
insert('first line\n')
|
|
|
|
for _ = 1, num_lines do
|
|
|
|
insert([[
|
|
|
|
line
|
|
|
|
]])
|
|
|
|
end
|
|
|
|
insert('last line')
|
|
|
|
|
2024-04-20 08:44:13 -07:00
|
|
|
n.feed('gg')
|
2024-02-05 05:38:42 -07:00
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
^first line |
|
|
|
|
line |*6
|
|
|
|
{1: }|
|
|
|
|
]],
|
|
|
|
attr_ids = {
|
|
|
|
[1] = { {}, { { kind = 'ui', hi_name = 'MsgArea', ui_name = 'MsgArea' } } },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
local ns = api.nvim_create_namespace('test')
|
|
|
|
|
|
|
|
local add_indicator = function(line, col)
|
|
|
|
api.nvim_buf_set_extmark(0, ns, line, col, {
|
|
|
|
hl_mode = 'combine',
|
|
|
|
priority = 2,
|
|
|
|
right_gravity = false,
|
|
|
|
virt_text = { { '|', 'Delimiter' } },
|
|
|
|
virt_text_win_col = 0,
|
|
|
|
virt_text_pos = 'overlay',
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
for i = 1, num_lines do
|
|
|
|
add_indicator(i, 0)
|
|
|
|
end
|
|
|
|
|
|
|
|
screen:expect {
|
|
|
|
grid = [[
|
|
|
|
^first line |
|
|
|
|
{1:|} line |*6
|
|
|
|
{2: }|
|
|
|
|
]],
|
|
|
|
attr_ids = {
|
|
|
|
[1] = {
|
|
|
|
{ foreground = Screen.colors.SlateBlue },
|
|
|
|
{ { kind = 'syntax', hi_name = 'Special' } },
|
|
|
|
},
|
|
|
|
[2] = { {}, { { kind = 'ui', ui_name = 'MsgArea', hi_name = 'MsgArea' } } },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-04-20 08:44:13 -07:00
|
|
|
n.feed(string.format('3ggV%ijd', num_lines - 2))
|
2024-02-05 05:38:42 -07:00
|
|
|
--screen:redraw_debug(nil, nil, 100000)
|
|
|
|
|
|
|
|
local expected_ids = {}
|
|
|
|
for i = 1, num_lines - 1 do
|
|
|
|
expected_ids[i] = 1
|
|
|
|
end
|
|
|
|
screen:expect {
|
|
|
|
grid = string.format(
|
|
|
|
[[
|
|
|
|
first line |
|
|
|
|
{1:|} line |
|
|
|
|
{2:^|}ast line |
|
|
|
|
{3:~ }|*4
|
|
|
|
{4:%-40s}|
|
|
|
|
]],
|
|
|
|
tostring(num_lines - 1) .. ' fewer lines'
|
|
|
|
),
|
|
|
|
attr_ids = {
|
|
|
|
[1] = {
|
|
|
|
{ foreground = Screen.colors.SlateBlue },
|
|
|
|
{ { kind = 'syntax', hi_name = 'Special' } },
|
|
|
|
},
|
|
|
|
[2] = { { foreground = Screen.colors.SlateBlue }, expected_ids },
|
|
|
|
[3] = {
|
|
|
|
{ foreground = Screen.colors.Blue, bold = true },
|
|
|
|
{ { kind = 'ui', hi_name = 'NonText', ui_name = 'EndOfBuffer' } },
|
|
|
|
},
|
|
|
|
[4] = { {}, { { kind = 'ui', hi_name = 'MsgArea', ui_name = 'MsgArea' } } },
|
|
|
|
},
|
|
|
|
timeout = 100000,
|
|
|
|
}
|
|
|
|
end)
|
2018-06-17 04:31:13 -07:00
|
|
|
end)
|