mirror of
https://github.com/neovim/neovim.git
synced 2026-05-04 21:15:09 +00:00
refactor(tests): all screen tests should use highlights
This is the first installment of a multi-PR series significantly refactoring how highlights are being specified. The end goal is to have a base set of 20 ish most common highlights, and then specific files only need to add more groups to that as needed. As a complicating factor, we also want to migrate to the new default color scheme eventually. But by sharing a base set, that future PR will hopefully be a lot smaller since a lot of tests will be migrated just simply by updating the base set in place. As a first step, fix the anti-pattern than Screen defaults to ignoring highlights. Highlights are integral part of the screen state, not something "extra" which we only test "sometimes". For now, we still allow opt-out via the intentionally ugly screen._default_attr_ids = nil The end goal is to get rid of all of these eventually (which will be easier as part of the color scheme migration)
This commit is contained in:
@@ -139,6 +139,43 @@ local function _init_colors()
|
||||
end
|
||||
Screen.colors = colors
|
||||
Screen.colornames = colornames
|
||||
|
||||
Screen._global_default_attr_ids = {
|
||||
[1] = { foreground = Screen.colors.Blue1, bold = true },
|
||||
[2] = { reverse = true },
|
||||
[3] = { bold = true, reverse = true },
|
||||
[4] = { background = Screen.colors.LightMagenta },
|
||||
[5] = { bold = true },
|
||||
[6] = { foreground = Screen.colors.SeaGreen, bold = true },
|
||||
[7] = { background = Screen.colors.Gray, foreground = Screen.colors.DarkBlue },
|
||||
[8] = { foreground = Screen.colors.Brown },
|
||||
[9] = { background = Screen.colors.Red, foreground = Screen.colors.Grey100 },
|
||||
[10] = { background = Screen.colors.Yellow },
|
||||
[11] = {
|
||||
foreground = Screen.colors.Blue1,
|
||||
background = Screen.colors.LightMagenta,
|
||||
bold = true,
|
||||
},
|
||||
[12] = { background = Screen.colors.Gray },
|
||||
[13] = { background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue },
|
||||
[14] = { background = Screen.colors.DarkGray, foreground = Screen.colors.LightGrey },
|
||||
[15] = { foreground = Screen.colors.Brown, bold = true },
|
||||
[16] = { foreground = Screen.colors.SlateBlue },
|
||||
[17] = { background = Screen.colors.LightGrey, foreground = Screen.colors.Black },
|
||||
[18] = { foreground = Screen.colors.Blue1 },
|
||||
[19] = { foreground = Screen.colors.Red },
|
||||
[20] = { background = Screen.colors.Yellow, foreground = Screen.colors.Red },
|
||||
[21] = { background = Screen.colors.Grey90 },
|
||||
[22] = { background = Screen.colors.LightBlue },
|
||||
[23] = { foreground = Screen.colors.Blue1, background = Screen.colors.LightCyan, bold = true },
|
||||
[24] = { background = Screen.colors.LightGrey, underline = true },
|
||||
[25] = { foreground = Screen.colors.Cyan4 },
|
||||
[26] = { foreground = Screen.colors.Fuchsia },
|
||||
[27] = { background = Screen.colors.Red, bold = true },
|
||||
[28] = { foreground = Screen.colors.SlateBlue, underline = true },
|
||||
[29] = { foreground = Screen.colors.SlateBlue, bold = true },
|
||||
[30] = { background = Screen.colors.Red },
|
||||
}
|
||||
end
|
||||
|
||||
--- @param width? integer
|
||||
@@ -257,6 +294,10 @@ function Screen:attach(options, session)
|
||||
if self._options.ext_multigrid then
|
||||
self._options.ext_linegrid = true
|
||||
end
|
||||
|
||||
if self._default_attr_ids == nil then
|
||||
self._default_attr_ids = Screen._global_default_attr_ids
|
||||
end
|
||||
end
|
||||
|
||||
function Screen:detach()
|
||||
@@ -480,7 +521,10 @@ function Screen:expect(expected, attr_ids, ...)
|
||||
attr_state.id_to_index = self:linegrid_check_attrs(attr_state.ids or {})
|
||||
end
|
||||
|
||||
local actual_rows = self:render(not expected.any, attr_state)
|
||||
local actual_rows
|
||||
if expected.any or grid then
|
||||
actual_rows = self:render(not expected.any, attr_state)
|
||||
end
|
||||
|
||||
if expected.any then
|
||||
-- Search for `any` anywhere in the screen lines.
|
||||
|
||||
Reference in New Issue
Block a user