aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2017-04-25 15:02:19 +0100
committerGitHub2017-04-25 15:02:19 +0100
commitc3b16da8391f4c37c79611f79f0ecadaa7b3b300 (patch)
tree0ccffab26e30a98845105a41dea9354908c49f46
parent7c96c19c434de5242727d1a662c327cd697bef71 (diff)
parentc1c8cb71383f3f36df6c93ba106cc51f03666e78 (diff)
downloadvimium-c3b16da8391f4c37c79611f79f0ecadaa7b3b300.tar.bz2
Merge pull request #2496 from mrmr1993/modes-exit
Make Mode::exit idempotent
-rw-r--r--content_scripts/mode.coffee19
1 files changed, 10 insertions, 9 deletions
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee
index 85187b2c..9de423ff 100644
--- a/content_scripts/mode.coffee
+++ b/content_scripts/mode.coffee
@@ -173,15 +173,16 @@ class Mode
@exitHandlers.push handler
exit: (args...) ->
- if @modeIsActive
- @log "deactivate:", @id
- unless @modeIsExiting
- @modeIsExiting = true
- handler args... for handler in @exitHandlers
- handlerStack.remove handlerId for handlerId in @handlers
- Mode.modes = Mode.modes.filter (mode) => mode != this
- @modeIsActive = false
- @setIndicator()
+ return if @modeIsExiting or not @modeIsActive
+ @log "deactivate:", @id
+ @modeIsExiting = true
+
+ handler args... for handler in @exitHandlers
+ handlerStack.remove handlerId for handlerId in @handlers
+ Mode.modes = Mode.modes.filter (mode) => mode != this
+
+ @modeIsActive = false
+ @setIndicator()
# Debugging routines.
logModes: ->