aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/screen.lua
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2024-03-22 11:02:52 +0100
committerbfredl <bjorn.linse@gmail.com>2024-03-23 13:44:35 +0100
commit0c59771e314d6faaad69676985cd2a11c157ee37 (patch)
treeb83d69de5f7a5877e26a4be8b882857a9477a437 /test/functional/ui/screen.lua
parentdc110cba3c0d48d7c9dbb91900f8be0cf6cf0c9b (diff)
downloadrneovim-0c59771e314d6faaad69676985cd2a11c157ee37.tar.gz
rneovim-0c59771e314d6faaad69676985cd2a11c157ee37.tar.bz2
rneovim-0c59771e314d6faaad69676985cd2a11c157ee37.zip
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)
Diffstat (limited to 'test/functional/ui/screen.lua')
-rw-r--r--test/functional/ui/screen.lua46
1 files changed, 45 insertions, 1 deletions
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index e8d7d5c72d..cfc6c14f5a 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -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.