History

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.

Avi Halachmi (:avih) committed 4 years ago

Commit 3694af61 parent 652f09a1 file · +1 −1Browse files

Showing the changes to player/javascript (1 of 1 file). Show all

Unified · Split

player/javascript/defaults.js+1−1
@@ -277,7 +277,7 @@ function dispatch_key_binding(name, state, key_name) { · 276 unmodified lines
277var binds_tid = 0; // flush timer id. actual id's are always true-thy277var binds_tid = 0; // flush timer id. actual id's are always true-thy
278mp.flush_key_bindings = function flush_key_bindings() {278mp.flush_key_bindings = function flush_key_bindings() {
279 function prioritized_inputs(arr) {279 function prioritized_inputs(arr) {
280 return arr.sort(function(a, b) { return a.id > b.id })280 return arr.sort(function(a, b) { return a.id - b.id })
281 .map(function(bind) { return bind.input });281 .map(function(bind) { return bind.input });
282 }282 }
283 283

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t