js: key bindings: ensure priorities for same-key - again

Commit 7f4841ff sorted the bindings so that if the same key was bound
more than once, then the newest binding takes priority (sorted last).

However, it got the comparison function wrong, which means the result
of the sort depended on the algorithm and not on the actual data, so
the priority for keys with more than one binding was still arbitraty.

Fix the sort function, and finally ensure that later binding acutally
override earlier bindings of the same key.
This commit is contained in:
Avi Halachmi (:avih) 2022-06-23 16:42:23 +03:00
parent 652f09a7a6
commit 3694af6076
1 changed files with 1 additions and 1 deletions

View File

@ -277,7 +277,7 @@ function dispatch_key_binding(name, state, key_name) {
var binds_tid = 0; // flush timer id. actual id's are always true-thy
mp.flush_key_bindings = function flush_key_bindings() {
function prioritized_inputs(arr) {
return arr.sort(function(a, b) { return a.id > b.id })
return arr.sort(function(a, b) { return a.id - b.id })
.map(function(bind) { return bind.input });
}