From fae035731fa8fe544abe174f97e7e5681726eb0c Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Thu, 22 May 2014 20:17:45 -0600 Subject: [PATCH] Prevent autoscrolling scroll-view when cursor is at end of longest line If the longest line is longer than the width of the scroll view, we need to allow 2px horizontally to prevent the hidden input from autoscrolling. --- src/editor-scroll-view-component.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/editor-scroll-view-component.coffee b/src/editor-scroll-view-component.coffee index 6ac3874db..92bc4a04e 100644 --- a/src/editor-scroll-view-component.coffee +++ b/src/editor-scroll-view-component.coffee @@ -169,6 +169,7 @@ EditorScrollViewComponent = React.createClass return {top: 0, left: 0} unless @isMounted() and focused and editor.getCursor()? {top, left, height, width} = editor.getCursor().getPixelRect() + width = 2 if width is 0 # Prevent autoscroll at the end of longest line top -= editor.getScrollTop() left -= editor.getScrollLeft() top = Math.max(0, Math.min(editor.getHeight() - height, top))