Add a second comparison for key bindings to avoid ties, GitHub issue

5647 from Alexandre Fiori.

(cherry picked from commit 86af3c8167)
This commit is contained in:
nicm
2026-09-28 09:41:53 +00:00
committed by Nicholas Marriott
parent 7405be7fa7
commit 9f16939a7e

12
sort.c
View File

@@ -1,4 +1,4 @@
/* $OpenBSD: sort.c,v 1.10 2026/08/25 07:23:30 nicm Exp $ */
/* $OpenBSD: sort.c,v 1.11 2026/09/28 09:41:53 nicm Exp $ */
/*
* Copyright (c) 2026 Dane Jensen <dhcjensen@gmail.com>
@@ -312,7 +312,7 @@ sort_key_binding_cmp(const void *a0, const void *b0)
(b->key & KEYC_MASK_MODIFIERS);
break;
case SORT_NAME:
result = strcasecmp(a->tablename, b->tablename) == 0;
result = strcasecmp(a->tablename, b->tablename);
break;
case SORT_ACTIVITY:
case SORT_CREATION:
@@ -324,7 +324,13 @@ sort_key_binding_cmp(const void *a0, const void *b0)
}
if (result == 0)
result = strcasecmp(a->tablename, b->tablename) == 0;
result = strcasecmp(a->tablename, b->tablename);
if (result == 0) {
if (a->key < b->key)
result = -1;
else if (a->key > b->key)
result = 1;
}
if (sort_crit->reversed)
result = -result;