Merge pull request #476 from kelvix/master
🐛 fix the race condition in beautify on save for setting cursor positions
This commit is contained in:
commit
955252b59d
|
@ -430,8 +430,15 @@ handleSaveEvent = ->
|
||||||
beautifyFilePath(filePath, ->
|
beautifyFilePath(filePath, ->
|
||||||
buffer.reload()
|
buffer.reload()
|
||||||
logger.verbose('restore editor positions', posArray,origScrollTop)
|
logger.verbose('restore editor positions', posArray,origScrollTop)
|
||||||
|
# Let the scrollTop setting run after all the save related stuff is run,
|
||||||
|
# otherwise setScrollTop is not working, probably because the cursor
|
||||||
|
# addition happens asynchronously
|
||||||
|
setTimeout ( ->
|
||||||
setCursors(editor, posArray)
|
setCursors(editor, posArray)
|
||||||
editor.setScrollTop(origScrollTop)
|
editor.setScrollTop(origScrollTop)
|
||||||
|
# console.log "setScrollTop"
|
||||||
|
return
|
||||||
|
), 0
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
plugin.subscribe disposable
|
plugin.subscribe disposable
|
||||||
|
@ -445,4 +452,3 @@ plugin.activate = ->
|
||||||
atom.commands.add "atom-workspace", "atom-beautify:help-debug-editor", debug
|
atom.commands.add "atom-workspace", "atom-beautify:help-debug-editor", debug
|
||||||
atom.commands.add ".tree-view .file .name", "atom-beautify:beautify-file", beautifyFile
|
atom.commands.add ".tree-view .file .name", "atom-beautify:beautify-file", beautifyFile
|
||||||
atom.commands.add ".tree-view .directory .name", "atom-beautify:beautify-directory", beautifyDirectory
|
atom.commands.add ".tree-view .directory .name", "atom-beautify:beautify-directory", beautifyDirectory
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue