From 4f426affde34c895cf342dac256895ffe98ee4f3 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 13 Jun 2015 13:03:10 +0100 Subject: Refactor duplicate code. --- content_scripts/mode_find.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'content_scripts/mode_find.coffee') diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee index 297c4158..bba457b6 100644 --- a/content_scripts/mode_find.coffee +++ b/content_scripts/mode_find.coffee @@ -87,7 +87,7 @@ class FindMode extends Mode findInPlace: (query) -> # If requested, restore the scroll position (so that failed searches leave the scroll position unchanged). - window.scrollTo @scrollX, @scrollY if @options.returnToViewport + @checkReturnToViewPort() FindMode.updateQuery query # Restore the selection. That way, we're always searching forward from the same place, so we find the right # match as the user adds matching characters, or removes previously-matched characters. See #1434. @@ -196,6 +196,9 @@ class FindMode extends Mode @restoreDefaultSelectionHighlight: -> document.body.classList.remove("vimiumFindMode") + checkReturnToViewPort: -> + window.scrollTo @scrollX, @scrollY if @options.returnToViewport + getCurrentRange = -> selection = getSelection() if selection.type == "None" -- cgit v1.2.3