Skip to content

Commit

Permalink
Fixed no-might-match input in context with modifier filter
Browse files Browse the repository at this point in the history
  • Loading branch information
houmain committed Jul 18, 2024
1 parent da966c3 commit d802a36
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/runtime/Stage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,11 @@ auto Stage::match_input(bool first_iteration,
if (no_might_match_mapping && (!first_iteration || m_history.empty()))
continue;

// no-might-match mappings are matched only
// when current event comes from a device
if (no_might_match_mapping && (device_index == any_device_index))
continue;

// might match is only accepted in first iteration (whole sequence)
const auto accept_might_match =
(first_iteration && !no_might_match_mapping);
Expand Down
16 changes: 16 additions & 0 deletions src/test/test4_Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,22 @@ TEST_CASE("Minimal configuration", "[Server]") {
CHECK(state.apply_input("-A") == "-B");
}


//--------------------------------------------------------------------

TEST_CASE("Modifier filter and no might match (infinite loop bug)", "[Server]") {
auto state = create_state(R"(
ContextActive >> Virtual1
[modifier = Virtual1]
? X >> A Virtual1
)");
CHECK(state.apply_input("+X") == "+A -A");
CHECK(state.apply_input("-X") == "");
CHECK(state.apply_input("+X") == "+X");
CHECK(state.apply_input("-X") == "-X");
}

//--------------------------------------------------------------------

TEST_CASE("Trigger Not Timeout", "[Server]") {
Expand Down

0 comments on commit d802a36

Please sign in to comment.