Files
voculinux/tests
Jatin K MalikandGitHub 49858f14e3 fix(ibus): capture current engine during prepare_engine for scoped activation (#458)
* fix(ibus): capture current engine during prepare_engine for scoped activation

Two bugs were causing IBus injection to fail and fall back to ydotool:

1. get_current_engine() returned empty string (falsy) when 'ibus engine'
   output was empty, instead of None. This caused inject_text() to think
   no engine was available.

2. prepare_engine() didn't capture the current IBus engine, so when
   inject_text() tried to get it at runtime, it would fail on systems
   where 'ibus engine' returns empty output.

Fix: get_current_engine() now returns None for empty output. prepare_engine()
captures the current engine before starting the Vocalinux process. inject_text()
uses the captured _previous_engine as fallback when get_current_engine() fails.

Fixes the regression from PR #457 where IBus injection would fail with:
  WARNING  Could not determine current IBus engine
  ERROR    IBus engine instance is not active and the previous engine
           could not be captured safely

* fix(ibus): always activate engine for injection on Wayland

On Wayland, 'ibus engine' returns empty output, so get_current_engine()
returns None. The previous code would skip activation when it couldn't
determine the current engine, causing injection to fail and fall back
to ydotool.

Now we always activate the Vocalinux engine when it's not active,
regardless of whether we can capture the previous engine. If we couldn't
capture it, we simply don't restore anything after injection.

This fixes the regression where IBus injection would fail with:
  WARNING  Could not determine current IBus engine
  ERROR    IBus engine instance is not active and the previous engine
           could not be captured safely

Fixes #458

* test(ibus): add missing mocks for is_engine_active and get_current_engine

Existing tests didn't mock is_engine_active() and get_current_engine(),
which are now called at the start of inject_text() for scoped activation.
This caused CI failures on Python 3.9-3.13 where the unmocked calls
would try to run 'ibus engine' and get unexpected results.
2026-06-06 20:41:15 -07:00
..