From e7f361942c2b07234e889804975e93c21c1f5baf Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Fri, 26 Feb 2016 14:31:33 +0100 Subject: [PATCH] Use `prefs.get` directly in events-frame.coffee ... instead of using `messageManager.get`. This avoids synchronous messages, which is a good thing. It violates the nice principle of only using the parsed options of the `vimfx` object, but it doesn't really matter right now since only four prefs are used in events-frame.coffee and they need little to none parsing. One could probably pass the entire `vimfx.options` object down to frame scripts when they start up and send updates whenever it updates, but let's do that when a need for it comes up. --- extension/lib/events-frame.coffee | 16 +++++----------- extension/lib/vim-frame.coffee | 2 -- extension/lib/vim.coffee | 10 ---------- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/extension/lib/events-frame.coffee b/extension/lib/events-frame.coffee index a78cd3e..d064fcf 100644 --- a/extension/lib/events-frame.coffee +++ b/extension/lib/events-frame.coffee @@ -22,6 +22,7 @@ notation = require('vim-like-key-notation') commands = require('./commands-frame') messageManager = require('./message-manager') +prefs = require('./prefs') utils = require('./utils') nsIFocusManager = Cc['@mozilla.org/focus-manager;1'] @@ -135,13 +136,12 @@ class FrameEventManager # behavior. Then, `event.key` is the way to go. (Unless the prefs are # customized. YAGNI until requested.) keyStr = notation.stringify(event) - options = @vim.options(['focus_previous_key', 'focus_next_key']) direction = switch keyStr when '' null - when options.focus_previous_key + when prefs.get('focus_previous_key') -1 - when options.focus_next_key + when prefs.get('focus_next_key') +1 else null @@ -205,15 +205,9 @@ class FrameEventManager @vim.state.lastFocusedTextInput = target @vim.state.hasFocusedTextInput = true - # When moving a tab to another window, there is a short period of time - # when there’s no listener for this call. - return unless options = @vim.options( - ['prevent_autofocus', 'prevent_autofocus_modes'] - ) - # Blur the focus target, if autofocus prevention is enabled… - if options.prevent_autofocus and - @vim.mode in options.prevent_autofocus_modes and + if prefs.get('prevent_autofocus') and + @vim.mode in prefs.get('prevent_autofocus_modes').split(/\s+/) and # …and the user has interacted with the page… not @vim.state.hasInteraction and # …and the event is programmatic (not caused by clicks or keypresses)… diff --git a/extension/lib/vim-frame.coffee b/extension/lib/vim-frame.coffee index 59bf596..6d4130a 100644 --- a/extension/lib/vim-frame.coffee +++ b/extension/lib/vim-frame.coffee @@ -74,8 +74,6 @@ class VimFrame # `markerElements` and `inputs` could theoretically need to be filtered # too at this point. YAGNI until an issue arises from it. - options: (prefs) -> messageManager.get('options', {prefs}) - enterMode: (@mode, args...) -> messageManager.send('vimMethod', { method: 'enterMode' diff --git a/extension/lib/vim.coffee b/extension/lib/vim.coffee index 00fbe04..5b05124 100644 --- a/extension/lib/vim.coffee +++ b/extension/lib/vim.coffee @@ -49,16 +49,6 @@ class Vim @_addListeners() _addListeners: -> - # Require the subset of the options needed to be listed explicitly (as - # opposed to sending _all_ options) for performance. Each option access - # might trigger an optionOverride. - @_listen('options', ({prefs}) => - options = {} - for pref in prefs - options[pref] = @options[pref] - return options - ) - @_listen('vimMethod', ({method, args = []}, callback = null) => result = @[method](args...) callback?(result) -- 2.39.3