diff --git a/src/view/PanelManager.js b/src/view/PanelManager.js index fe7edb0b1bc..9b863731612 100644 --- a/src/view/PanelManager.js +++ b/src/view/PanelManager.js @@ -99,6 +99,28 @@ define(function (require, exports, module) { $panel.on("panelCollapsed panelExpanded panelResizeUpdate", function () { triggerEditorResize(); }); + + $panel.on("panelExpanded", function () { + var _currentEditor = EditorManager.getCurrentFullEditor(); + + // Make sure that we're not switching files + // and still on an active editor + if (_currentEditor) { + + // Gather info to determine whether to scroll after editor resizes + var height = _currentEditor._codeMirror.getScrollInfo().clientHeight, + textHeight = _currentEditor.getTextHeight(), + cursorTop = _currentEditor._codeMirror.cursorCoords().top, + bottom = cursorTop - $("#editor-holder").offset().top + textHeight - height; + + // Determine whether panel would block text at cursor + // If so, scroll the editor to expose the cursor above + // the panel + if (bottom <= $panel.height() && bottom >= 5) { + _currentEditor._codeMirror.scrollIntoView(); + } + } + }); }