aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorStephen Blott2017-04-14 07:48:56 +0100
committerStephen Blott2017-04-18 05:50:51 +0100
commit4c32c0383964e178e0196a87df7fc7a4ad7f8f27 (patch)
tree33de054047b6f87f49b060167495cd096c5a163c /lib
parent40ece51a53ee4042caad7854e415de56c0c69cab (diff)
downloadvimium-4c32c0383964e178e0196a87df7fc7a4ad7f8f27.tar.bz2
Use event.code to detect/suppress keyup events.
This avoids the possibility of leaking keyup events if the keys a released in a different order from that in which they were pressed. Also, replace suppressKeyupAfterEscape with this same mechanism. This fixes a bug (in master/1.59) whereby we leak the keyup event for `i` when entering insert mode. TODO: - `/`, `<Escape>` leaks a keyup event - `i` leaks a keyup event
Diffstat (limited to 'lib')
-rw-r--r--lib/dom_utils.coffee19
1 files changed, 3 insertions, 16 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index 8764bdbe..3f0bd7f3 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -305,27 +305,13 @@ DomUtils =
event.preventDefault()
@suppressPropagation(event)
- # Suppress the next keyup event for Escape.
- suppressKeyupAfterEscape: (handlerStack) ->
- handlerStack.push
- _name: "dom_utils/suppressKeyupAfterEscape"
- keyup: (event) ->
- return true unless KeyboardUtils.isEscape event
- @remove()
- false
- handlerStack.suppressEvent
-
consumeKeyup: (event, callback = null) ->
- @suppressEvent event
- keyChar = KeyboardUtils.getKeyCharString event
+ code = event.code
unless event.repeat
handlerStack.push
_name: "dom_utils/consumeKeyup"
- keydown: (event) ->
- @remove()
- handlerStack.continueBubbling
keyup: (event) ->
- return handlerStack.continueBubbling unless keyChar == KeyboardUtils.getKeyCharString event
+ return handlerStack.continueBubbling unless event.code == code
@remove()
handlerStack.suppressEvent
# We cannot track keyup events if we lose the focus.
@@ -333,6 +319,7 @@ DomUtils =
@remove() if event.target == window
handlerStack.continueBubbling
callback?()
+ @suppressEvent event
handlerStack.suppressEvent
# Adapted from: http://roysharon.com/blog/37.