From 37d6ac8a15a97e54c1e75718e146cb6d1b6f74bd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 11 Jun 2025 09:56:12 +0800 Subject: [PATCH] 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:}. --- test/functional/terminal/tui_spec.lua | 4 +++- test/functional/ui/screen.lua | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index f858f7bd91..a5a894549b 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -113,11 +113,13 @@ 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([[ Hello, World^ | {4:~ }|*3 - {MATCH:No Name} + {5:[No Name] [+]{MATCH: *}}{MATCH: *}| {3:-- INSERT --} | {3:-- TERMINAL --} | ]]) diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 4a16347bb1..46d65e2045 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -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