Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always retain later Compose sequence in case of conflict #570

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changes/api/+compose-new-overrides-old.breaking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Changed Compose behavior so that sequences defined later always override
ones defined earlier, even if the new sequence is shorter.
6 changes: 1 addition & 5 deletions include/xkbcommon/xkbcommon-compose.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ extern "C" {
* @parblock
*
* To avoid ambiguity, a sequence is not allowed to be a prefix of another.
* In such a case, the conflict is resolved thus:
*
* 1. A longer sequence overrides a shorter one.
* 2. An equal sequence overrides an existing one.
* 3. A shorter sequence does not override a longer one.
* When such a conflict occurs, the sequence defined last is the one retained.
*
* Sequences of length 1 are allowed.
*
Expand Down
4 changes: 2 additions & 2 deletions src/compose/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@ add_production(struct xkb_compose_table *table, struct scanner *s,
} else if (node->internal.eqkid != 0) {
scanner_warn(s, XKB_LOG_MESSAGE_NO_ID,
"this compose sequence is a prefix of another; "
"skipping line");
return;
"overriding");
node->internal.eqkid = 0;
}
node->is_leaf = true;
if (production->has_string) {
Expand Down
4 changes: 2 additions & 2 deletions test/compose.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ test_conflicting(struct xkb_context *ctx)
"<A> <B> <C> : \"foo\" A \n"
"<A> <B> : \"bar\" B \n",
XKB_KEY_A, XKB_COMPOSE_FEED_ACCEPTED, XKB_COMPOSE_COMPOSING, "", XKB_KEY_NoSymbol,
XKB_KEY_B, XKB_COMPOSE_FEED_ACCEPTED, XKB_COMPOSE_COMPOSING, "", XKB_KEY_NoSymbol,
XKB_KEY_C, XKB_COMPOSE_FEED_ACCEPTED, XKB_COMPOSE_COMPOSED, "foo", XKB_KEY_A,
XKB_KEY_B, XKB_COMPOSE_FEED_ACCEPTED, XKB_COMPOSE_COMPOSED, "bar", XKB_KEY_B,
XKB_KEY_C, XKB_COMPOSE_FEED_ACCEPTED, XKB_COMPOSE_NOTHING, "", XKB_KEY_NoSymbol,
XKB_KEY_NoSymbol));

// old is a prefix of new
Expand Down
Loading