diff options
| author | Stephen Blott | 2015-10-04 12:22:18 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-10-04 12:22:18 +0100 |
| commit | 7158cd670ae5824ebeb134fe3ec35472e4dc692f (patch) | |
| tree | b3d016cd87b7c3ac76294f9318e16adcaaa01ee2 | |
| parent | 1c1bfb8d070ccbae1307c40e0b0a12afb6f65219 (diff) | |
| download | vimium-7158cd670ae5824ebeb134fe3ec35472e4dc692f.tar.bz2 | |
Make mode.exit() idempotent.
We've been calling hintMode.exit() twice: once explicitly, and once as a
side effect of the simulated click event.
Since there are so many code paths through link hints, it seems better
to simply explicitly make mode.exit() idempotent for all modes. Which
is what this commit does.
| -rw-r--r-- | content_scripts/mode.coffee | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee index cab97b32..c7c6bd55 100644 --- a/content_scripts/mode.coffee +++ b/content_scripts/mode.coffee @@ -41,6 +41,7 @@ class Mode @handlers = [] @exitHandlers = [] @modeIsActive = true + @modeIsExiting = false @name = @options.name || "anonymous" @count = ++count @@ -189,8 +190,10 @@ class Mode exit: -> if @modeIsActive @log "deactivate:", @id - handler() for handler in @exitHandlers - handlerStack.remove handlerId for handlerId in @handlers + unless @modeIsExiting + @modeIsExiting = true + handler() for handler in @exitHandlers + handlerStack.remove handlerId for handlerId in @handlers Mode.modes = Mode.modes.filter (mode) => mode != @ @modeIsActive = false @setIndicator() |
