From 9b669f56771d3b82cb30683e69ceda93d4ffe837 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Fri, 14 Oct 2016 20:24:34 +0200 Subject: [PATCH] Fix element focusing with `f` commands Fixes #825. --- extension/lib/commands-frame.coffee | 4 ++-- extension/lib/hints-mode.coffee | 9 ++++++--- extension/lib/utils.coffee | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/extension/lib/commands-frame.coffee b/extension/lib/commands-frame.coffee index b99f698..e6d01e9 100644 --- a/extension/lib/commands-frame.coffee +++ b/extension/lib/commands-frame.coffee @@ -686,8 +686,8 @@ commands.collapse_selection = ({vim}) -> return unless selectionManager = helper_create_selection_manager(vim) selectionManager.collapse() -commands.clear_selection = ({vim}) -> - utils.clearSelectionDeep(vim.content) +commands.clear_selection = ({vim, skipBlurring}) -> + utils.clearSelectionDeep(vim.content, {skipBlurring}) commands.modal = ({vim, type, args}) -> return vim.content[type](args...) diff --git a/extension/lib/hints-mode.coffee b/extension/lib/hints-mode.coffee index e0018c1..b6ca93f 100644 --- a/extension/lib/hints-mode.coffee +++ b/extension/lib/hints-mode.coffee @@ -48,7 +48,10 @@ activateMatch = (vim, storage, match, matchedMarkers, callback) -> vim.window.setTimeout((-> # Don’t clean up if Hints mode has been re-entered before the # timeout has passed. - cleanup(vim, storage) unless vim.mode == 'hints' + unless vim.mode == 'hints' + # Don’t blur frames (in `utils.clearSelectionDeep`) in case the callback + # has focused something in a frame. + cleanup(vim, storage, {skipBlurring: true}) ), vim.options['hints.matched_timeout']) unless switchedMode @@ -56,10 +59,10 @@ activateMatch = (vim, storage, match, matchedMarkers, callback) -> vim._enterMode('normal') storage.skipOnLeaveCleanup = false -cleanup = (vim, storage) -> +cleanup = (vim, storage, options = {}) -> {markerContainer, matchText} = storage markerContainer?.remove() - vim._run('clear_selection') if matchText and vim.mode != 'caret' + vim._run('clear_selection', options) if matchText and vim.mode != 'caret' if vim.options.notify_entered_keys and markerContainer.enteredText == vim._state.lastNotification vim.hideNotification() diff --git a/extension/lib/utils.coffee b/extension/lib/utils.coffee index 57c7d01..0bba3eb 100644 --- a/extension/lib/utils.coffee +++ b/extension/lib/utils.coffee @@ -372,14 +372,14 @@ checkElementOrAncestor = (element, fn) -> element = element.parentElement return false -clearSelectionDeep = (window) -> +clearSelectionDeep = (window, {skipBlurring = false} = {}) -> # The selection might be `null` in hidden frames. selection = window.getSelection() selection?.removeAllRanges() for frame in window.frames clearSelectionDeep(frame) # Allow parents to re-gain control of text selection. - frame.frameElement.blur() + frame.frameElement.blur() unless skipBlurring return containsDeep = (parent, element) -> -- 2.39.3