fix: update test helper for flush-forward behavior, 67 tests pass

- Engine no longer includes flush char in Replace insert
- Daemon forwards raw flush key after Replace injection
- Test helper simulates this by adding Insert event after Replace
This commit is contained in:
Khoa Vo 2026-06-26 16:55:57 +07:00
parent 758eea45b3
commit 118b601d0e

View file

@ -6,16 +6,23 @@ mod tests {
let mut events = Vec::new();
for ch in input.chars() {
if let Some(event) = engine.process_key(ch) {
let is_replace = matches!(&event, EngineEvent::Replace { .. });
let fl = is_flush_char(ch);
events.push(event);
if is_replace && fl {
events.push(EngineEvent::Insert(ch.to_string()));
}
} else if engine.is_enabled() {
// Engine didn't produce an event — the daemon would forward the raw key.
// Track this as an Insert for display reconstruction.
events.push(EngineEvent::Insert(ch.to_string()));
}
}
events
}
fn is_flush_char(ch: char) -> bool {
matches!(ch, ' ' | '\t' | '.' | ',' | '!' | '?' | ';' | ':' | '\n')
}
fn get_display(events: &[EngineEvent]) -> String {
let mut display = String::new();
for ev in events {