refactor(tests): allow to extend the new base set of attrs

We start at 100 so we can make the base set larger if needed. (It might need to
grow/shrink as a result of adopting the new default color scheme as the
default for tests)

Usage best illustrataded by example.

Improving the workflow for making new tests with `screen:snapshot_util()` will
be a follow up.
This commit is contained in:
bfredl
2024-04-02 11:46:48 +02:00
parent d9235efa76
commit fa74f75710
3 changed files with 252 additions and 281 deletions

View File

@@ -255,6 +255,17 @@ function Screen:set_default_attr_ids(attr_ids)
self._default_attr_ids = attr_ids
end
function Screen:add_extra_attr_ids(extra_attr_ids)
local attr_ids = vim.deepcopy(Screen._global_default_attr_ids)
for id, attr in pairs(extra_attr_ids) do
if type(id) == 'number' and id < 100 then
error('extra attr ids should be at least 100 or be strings')
end
attr_ids[id] = attr
end
self._default_attr_ids = attr_ids
end
function Screen:get_default_attr_ids()
return deepcopy(self._default_attr_ids)
end