From bbae6043d52f3356e67dacfdca50a9a851a780b0 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Sat, 2 Apr 2016 11:05:16 +1100 Subject: [PATCH] Fix deprecation warnings triggered by TextEditor methods --- src/beautify.coffee | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/beautify.coffee b/src/beautify.coffee index 727dd12..2d155b0 100644 --- a/src/beautify.coffee +++ b/src/beautify.coffee @@ -27,6 +27,13 @@ $ = null # nopt.clean(data, types); # return data; # } +getScrollTop = (editor) -> + view = editor.viewRegistry.getView(editor) + view.getScrollTop() +setScrollTop = (editor, value) -> + view = editor.viewRegistry.getView(editor) + view.setScrollTop value + getCursors = (editor) -> cursors = editor.getCursors() posArray = [] @@ -109,7 +116,7 @@ beautify = ({onSave}) -> posArray = getCursors(editor) # console.log "posArray: - origScrollTop = editor.getScrollTop() + origScrollTop = getScrollTop(editor) # console.log "origScrollTop: if not forceEntireFile and isSelection @@ -132,7 +139,7 @@ beautify = ({onSave}) -> setTimeout ( -> # console.log "setScrollTop" - editor.setScrollTop origScrollTop + setScrollTop editor, origScrollTop return ), 0 else @@ -495,7 +502,7 @@ handleSaveEvent = -> logger.verbose('save editor positions', key, beautifyOnSave) if beautifyOnSave posArray = getCursors(editor) - origScrollTop = editor.getScrollTop() + origScrollTop = getScrollTop(editor) beautifyFilePath(filePath, -> if editor.isAlive() is true buffer.reload() @@ -505,7 +512,7 @@ handleSaveEvent = -> # addition happens asynchronously setTimeout ( -> setCursors(editor, posArray) - editor.setScrollTop(origScrollTop) + setScrollTop(editor, origScrollTop) # console.log "setScrollTop" return ), 0