diff options
| author | mrmr1993 | 2017-04-24 20:41:42 +0100 |
|---|---|---|
| committer | mrmr1993 | 2017-04-24 20:48:26 +0100 |
| commit | c1c8cb71383f3f36df6c93ba106cc51f03666e78 (patch) | |
| tree | 0ccffab26e30a98845105a41dea9354908c49f46 | |
| parent | 7c96c19c434de5242727d1a662c327cd697bef71 (diff) | |
| download | vimium-c1c8cb71383f3f36df6c93ba106cc51f03666e78.tar.bz2 | |
Make Mode::exit idempotent
| -rw-r--r-- | content_scripts/mode.coffee | 19 |
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: -> |
