From bed545c4372a3ea309452b86653fdccdd6eadd41 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sat, 5 Nov 2016 18:32:29 +0100 Subject: [PATCH] Fix the `n` and `N` commands in PDF.js tabs Fixes #827. --- extension/lib/commands.coffee | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/extension/lib/commands.coffee b/extension/lib/commands.coffee index 3bfbb62..733938f 100644 --- a/extension/lib/commands.coffee +++ b/extension/lib/commands.coffee @@ -865,14 +865,30 @@ helper_find_again = (direction, {vim}) -> helper_find_from_top_of_viewport(vim, direction, -> findBar._findField.value = findStorage.lastSearchString - # Temporarily hack `.onFindResult` to be able to know when the asynchronous - # `.onFindAgainCommand` is done. + # `.onFindResult` is temporarily hacked to be able to know when the + # asynchronous `.onFindAgainCommand` is done. When PDFs are shown using + # PDF.js, `.updateControlState` is called instead of `.onFindResult`, so + # hack that one too. originalOnFindResult = findBar.onFindResult + originalUpdateControlState = findBar.updateControlState + findBar.onFindResult = (data) -> # Prevent the find bar from re-opening if there are no matches. data.storeResult = false findBar.onFindResult = originalOnFindResult + findBar.updateControlState = originalUpdateControlState findBar.onFindResult(data) + callback() + + findBar.updateControlState = (args...) -> + # Firefox inconsistently _doesn’t_ re-open the find bar if there are no + # matches here, so no need to take care of that in this case. + findBar.onFindResult = originalOnFindResult + findBar.updateControlState = originalUpdateControlState + findBar.updateControlState(args...) + callback() + + callback = -> message = findBar._findStatusDesc.textContent vim.notify(message) if message findStorage.busy = false -- 2.39.3