Skip to content

Commit 245d5c6

Browse files
committed
test(windows): ignore buffered transition release
1 parent a87e1fc commit 245d5c6

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

examples/windows-vt-input.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,18 @@ mod windows {
153153
println!("{label}: mode=0x{mode:08x}, VT_INPUT={vt_input}");
154154
}
155155

156+
fn is_transition_p(event: &Event) -> bool {
157+
matches!(
158+
event,
159+
Event::Key(key) if matches!(key.code, KeyCode::Char('p') | KeyCode::Char('P'))
160+
)
161+
}
162+
163+
fn is_transition_p_release(event: &Event) -> bool {
164+
is_transition_p(event)
165+
&& matches!(event, Event::Key(key) if key.kind == KeyEventKind::Release)
166+
}
167+
156168
fn read_phase(
157169
stats: &mut SessionStats,
158170
phase: &str,
@@ -170,23 +182,18 @@ mod windows {
170182
{
171183
println!("Event: {event:?}");
172184
}
173-
let phase_transition_key = phase.starts_with("Phase 1")
174-
&& matches!(
175-
&event,
176-
Event::Key(key)
177-
if matches!(key.code, KeyCode::Char('p') | KeyCode::Char('P'))
178-
);
179-
let phase_transition_release = phase_transition_key
180-
&& matches!(&event, Event::Key(key) if key.kind == KeyEventKind::Release);
185+
// The phase gate applies only to transitioning out of Phase 1. The
186+
// Phase 2 buffered-release cleanup must use the key identity alone.
187+
let transition_p = is_transition_p(&event);
188+
let phase_transition_key = phase.starts_with("Phase 1") && transition_p;
189+
let phase_transition_release = phase_transition_key && is_transition_p_release(&event);
181190
let exit = matches!(
182191
&event,
183192
Event::Key(key) if key.code == KeyCode::Esc && key.kind == KeyEventKind::Press
184193
);
185194
if ignore_next_transition_release {
186195
ignore_next_transition_release = false;
187-
if phase_transition_key
188-
&& matches!(&event, Event::Key(key) if key.kind == KeyEventKind::Release)
189-
{
196+
if is_transition_p_release(&event) {
190197
println!("Ignoring the buffered Phase 1 transition P release in Phase 2");
191198
continue;
192199
}

0 commit comments

Comments
 (0)