mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #411 from sharelatex/ja-fix-cursor-on-resize
Ja fix cursor on resize
This commit is contained in:
commit
d44a0ece97
1 changed files with 12 additions and 0 deletions
|
@ -167,10 +167,22 @@ define [
|
|||
if arg == "/"
|
||||
ace.require("ace/ext/searchbox").Search(editor, true)
|
||||
|
||||
getCursorScreenPosition = () ->
|
||||
session = editor.getSession()
|
||||
cursorPosition = session.selection.getCursor()
|
||||
sessionPos = session.documentToScreenPosition(cursorPosition.row, cursorPosition.column)
|
||||
screenPos = editor.renderer.textToScreenCoordinates(sessionPos.row, sessionPos.column)
|
||||
return sessionPos.row * editor.renderer.lineHeight - session.getScrollTop()
|
||||
|
||||
if attrs.resizeOn?
|
||||
for event in attrs.resizeOn.split(",")
|
||||
scope.$on event, () ->
|
||||
previousScreenPosition = getCursorScreenPosition()
|
||||
editor.resize()
|
||||
# Put cursor back to same vertical position on screen
|
||||
newScreenPosition = getCursorScreenPosition()
|
||||
session = editor.getSession()
|
||||
session.setScrollTop(session.getScrollTop() + newScreenPosition - previousScreenPosition)
|
||||
|
||||
scope.$watch "theme", (value) ->
|
||||
editor.setTheme("ace/theme/#{value}")
|
||||
|
|
Loading…
Reference in a new issue