From 3694af60769a58d491011ea42f208ffcb7181d9a Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Thu, 23 Jun 2022 16:42:23 +0300 Subject: 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. --- player/javascript/defaults.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/player/javascript/defaults.js b/player/javascript/defaults.js index a938ffef65..d906ec2448 100644 --- a/player/javascript/defaults.js +++ b/player/javascript/defaults.js @@ -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 }); } -- cgit v1.2.3