aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/mode_find.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'content_scripts/mode_find.coffee')
-rw-r--r--content_scripts/mode_find.coffee12
1 files changed, 9 insertions, 3 deletions
diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee
index 0178527b..63825600 100644
--- a/content_scripts/mode_find.coffee
+++ b/content_scripts/mode_find.coffee
@@ -87,7 +87,7 @@ class FindMode extends Mode
selection.removeAllRanges()
selection.addRange range
- findInPlace: (query) ->
+ findInPlace: (query, options) ->
# If requested, restore the scroll position (so that failed searches leave the scroll position unchanged).
@checkReturnToViewPort()
FindMode.updateQuery query
@@ -95,7 +95,7 @@ class FindMode extends Mode
# match as the user adds matching characters, or removes previously-matched characters. See #1434.
@restoreSelection()
query = if FindMode.query.isRegex then FindMode.getNextQueryFromRegexMatches(0) else FindMode.query.parsedQuery
- FindMode.query.hasResults = FindMode.execute query
+ FindMode.query.hasResults = FindMode.execute query, options
@updateQuery: (query) ->
@query.rawQuery = query
@@ -178,7 +178,13 @@ class FindMode extends Mode
# ignore the selectionchange event generated by find()
document.removeEventListener("selectionchange", @restoreDefaultSelectionHighlight, true)
- result = window.find(query, options.caseSensitive, options.backwards, true, false, true, false)
+ try
+ result = window.find(query, options.caseSensitive, options.backwards, true, false, true, false)
+ catch # Failed searches throw on Firefox.
+
+ # window.find focuses the |window| that it is called on. This gives us an opportunity to (re-)focus
+ # another element/window, if that isn't the behaviour we want.
+ options.postFindFocus?.focus()
if options.colorSelection
setTimeout(