diff options
| author | Stephen Blott | 2017-04-25 15:02:19 +0100 | 
|---|---|---|
| committer | GitHub | 2017-04-25 15:02:19 +0100 | 
| commit | c3b16da8391f4c37c79611f79f0ecadaa7b3b300 (patch) | |
| tree | 0ccffab26e30a98845105a41dea9354908c49f46 | |
| parent | 7c96c19c434de5242727d1a662c327cd697bef71 (diff) | |
| parent | c1c8cb71383f3f36df6c93ba106cc51f03666e78 (diff) | |
| download | vimium-c3b16da8391f4c37c79611f79f0ecadaa7b3b300.tar.bz2 | |
Merge pull request #2496 from mrmr1993/modes-exit
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: -> | 
