mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
@@ -269,7 +269,7 @@ local ext_keys = {
|
||||
-- grid: Expected screen state (string). Each line represents a screen
|
||||
-- row. Last character of each row (typically "|") is stripped.
|
||||
-- Common indentation is stripped.
|
||||
-- Lines containing only "{IGNORE}|" are skipped.
|
||||
-- "{MATCH:x}|" lines are matched against Lua pattern `x`.
|
||||
-- attr_ids: Expected text attributes. Screen rows are transformed according
|
||||
-- to this table, as follows: each substring S composed of
|
||||
-- characters having the same attributes will be substituted by
|
||||
@@ -390,18 +390,16 @@ function Screen:expect(expected, attr_ids, ...)
|
||||
err_msg = "Expected screen height " .. #expected_rows
|
||||
.. ' differs from actual height ' .. #actual_rows .. '.'
|
||||
end
|
||||
for i = 1, #expected_rows do
|
||||
msg_expected_rows[i] = expected_rows[i]
|
||||
if expected_rows[i] ~= actual_rows[i] and expected_rows[i] ~= "{IGNORE}|" then
|
||||
local m = expected_rows[i]:match('{MATCH:(.*)}')
|
||||
if not m or not actual_rows[i]:match(m) then
|
||||
msg_expected_rows[i] = '*' .. msg_expected_rows[i]
|
||||
if i <= #actual_rows then
|
||||
actual_rows[i] = '*' .. actual_rows[i]
|
||||
end
|
||||
if err_msg == nil then
|
||||
err_msg = 'Row ' .. tostring(i) .. ' did not match.'
|
||||
end
|
||||
for i, row in ipairs(expected_rows) do
|
||||
msg_expected_rows[i] = row
|
||||
local m = (row ~= actual_rows[i] and row:match('{MATCH:(.*)}') or nil)
|
||||
if row ~= actual_rows[i] and (not m or not actual_rows[i]:match(m)) then
|
||||
msg_expected_rows[i] = '*' .. msg_expected_rows[i]
|
||||
if i <= #actual_rows then
|
||||
actual_rows[i] = '*' .. actual_rows[i]
|
||||
end
|
||||
if err_msg == nil then
|
||||
err_msg = 'Row ' .. tostring(i) .. ' did not match.'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user