From 91767943290f799ce99a935a8ce19f1766508d91 Mon Sep 17 00:00:00 2001
From: Stephen Blott
Date: Wed, 11 Feb 2015 05:47:05 +0000
Subject: Fix error on yank/scroll.
When we exit visual mode with "y"...
"y" is a command for visual mode. Currently it clears the selection.
Because it's executed as a command, scrollIntoView is called after
running the command. Because the selection is cleared, scrollIntoView
found nothing to scroll, and was creating an error.
So we need to check whether there's anything to scroll into view, before
trying to scroll it.
Also fix mis-named file in the tests.
---
content_scripts/mode_visual_edit.coffee | 5 +++--
tests/dom_tests/dom_tests.html | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/content_scripts/mode_visual_edit.coffee b/content_scripts/mode_visual_edit.coffee
index e11c29ec..16872140 100644
--- a/content_scripts/mode_visual_edit.coffee
+++ b/content_scripts/mode_visual_edit.coffee
@@ -456,8 +456,9 @@ class Movement extends CountPrefix
coords = DomUtils.getCaretCoordinates @element, position
Scroller.scrollToPosition @element, coords.top, coords.left
else
- elementWithFocus = DomUtils.getElementWithFocus @selection, @getDirection() == backward
- Scroller.scrollIntoView elementWithFocus if elementWithFocus
+ unless @selection.type == "None"
+ elementWithFocus = DomUtils.getElementWithFocus @selection, @getDirection() == backward
+ Scroller.scrollIntoView elementWithFocus if elementWithFocus
class VisualMode extends Movement
constructor: (options = {}) ->
diff --git a/tests/dom_tests/dom_tests.html b/tests/dom_tests/dom_tests.html
index 33759abd..cbd91bca 100644
--- a/tests/dom_tests/dom_tests.html
+++ b/tests/dom_tests/dom_tests.html
@@ -43,7 +43,7 @@
-
+
--
cgit v1.2.3