mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test: print screen snapshot in desired format (#28088)
Problem: Screen snapshot is printed in a way that still needs to be formatted. Solution: Adjust the snapshot formatting (indentation, braces).
This commit is contained in:
parent
4e56f7f0be
commit
e2224a7933
@ -1689,20 +1689,23 @@ function Screen:_print_snapshot(attrs, ignore)
|
|||||||
dict = '{ ' .. self:_pprint_attrs(a) .. ' }'
|
dict = '{ ' .. self:_pprint_attrs(a) .. ' }'
|
||||||
end
|
end
|
||||||
local keyval = (type(i) == 'number') and '[' .. tostring(i) .. ']' or i
|
local keyval = (type(i) == 'number') and '[' .. tostring(i) .. ']' or i
|
||||||
table.insert(attrstrs, ' ' .. keyval .. ' = ' .. dict .. ';')
|
table.insert(attrstrs, ' ' .. keyval .. ' = ' .. dict .. ',')
|
||||||
end
|
end
|
||||||
attrstr = (', attr_ids={\n' .. table.concat(attrstrs, '\n') .. '\n}')
|
attrstr = (',\n attr_ids = {\n ' .. table.concat(attrstrs, '\n ') .. '\n },')
|
||||||
elseif isempty(attrs) then
|
elseif isempty(attrs) then
|
||||||
attrstr = ', attr_ids={}'
|
attrstr = ',\n attr_ids = {},'
|
||||||
end
|
end
|
||||||
|
|
||||||
local result = 'screen:expect{grid=[[\n' .. kwargs.grid .. '\n]]' .. attrstr
|
local result = ('screen:expect({\n grid = [[\n %s\n ]]%s'):format(
|
||||||
|
kwargs.grid:gsub('\n', '\n '),
|
||||||
|
attrstr
|
||||||
|
)
|
||||||
for _, k in ipairs(ext_keys) do
|
for _, k in ipairs(ext_keys) do
|
||||||
if ext_state[k] ~= nil and not (k == 'win_viewport' and not self.options.ext_multigrid) then
|
if ext_state[k] ~= nil and not (k == 'win_viewport' and not self.options.ext_multigrid) then
|
||||||
result = result .. ', ' .. k .. '=' .. fmt_ext_state(k, ext_state[k])
|
result = result .. ', ' .. k .. '=' .. fmt_ext_state(k, ext_state[k])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
result = result .. '}'
|
result = result .. '\n})'
|
||||||
|
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user