test(screen): still match by full row when {MATCH:} is present (#34437)

Add '^' and '$' around the pattern. This makes it less likely to make
mistakes of when writing tests with {MATCH:}, as most such tests have
text before and after {MATCH:}.

(cherry picked from commit 37d6ac8a15)
This commit is contained in:
zeertzjq
2025-06-11 09:56:12 +08:00
committed by github-actions[bot]
parent d28ad6e03f
commit c5bc0289ed
2 changed files with 4 additions and 1 deletions

View File

@@ -126,12 +126,14 @@ describe('TUI :detach', function()
nvim_set .. ' notermguicolors laststatus=2 background=dark',
}, job_opts)
--- FIXME: On Windows spaces at the end of a screen line may have wrong attrs.
--- Remove the {MATCH:} when that's fixed.
tt.feed_data('iHello, World')
screen:expect {
grid = [[
Hello, World^ |
{4:~ }|*3
{MATCH:No Name}
{5:[No Name] [+]{MATCH: *}}{MATCH: *}|
{3:-- INSERT --} |
{3:-- TERMINAL --} |
]],

View File

@@ -586,6 +586,7 @@ function Screen:expect(expected, attr_ids, ...)
after = after:sub(e + 1)
end
end
pat = pat and '^' .. pat .. '$'
if row ~= actual_rows[i] and (not pat or not actual_rows[i]:match(pat)) then
msg_expected_rows[i] = '*' .. msg_expected_rows[i]
if i <= #actual_rows then