From 84efe44a5a4d0126bd1037b1a0fce5a53776fb28 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 25 Sep 2013 11:53:14 -0700 Subject: [PATCH] Always keep hidden input position in visible area Previously the input could be offscreen depend on the scroll position of the editor and this would cause a scroll event to occur when the input gained focused causing the editor rendering to go out of sync. --- src/editor.coffee | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/editor.coffee b/src/editor.coffee index 6f5a505ee..73dd9db41 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -630,6 +630,7 @@ class Editor extends View handleEvents: -> @on 'focus', => + @updateHiddenInputOffset() @hiddenInput.focus() false @@ -693,10 +694,15 @@ class Editor extends View else @gutter.addClass('drop-shadow') + updateHiddenInputOffset: -> + cursorView = @getCursorView() + if cursorView?.is(':visible') + offset = cursorView.offset() + offset.top = Math.min(@height(), offset.top) + @hiddenInput.offset(offset) + handleInputEvents: -> - @on 'cursor:moved', => - cursorView = @getCursorView() - @hiddenInput.offset(cursorView.offset()) if cursorView.is(':visible') + @on 'cursor:moved', => @updateHiddenInputOffset() selectedText = null @hiddenInput.on 'compositionstart', =>