Skip to content

Commit 686cdf7

Browse files
authored
Merge pull request #742 from JunoLab/sp/restorecursorpos
restore cursor pos when formating
2 parents 5487096 + fc8551a commit 686cdf7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/runtime/formatter.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ function formatEditorTextInRange (editor, range, text) {
4949
})
5050
} else {
5151
if (marker.isValid()) {
52+
const pos = editor.getCursorBufferPosition()
5253
editor.setTextInBufferRange(marker.getBufferRange(), formattedtext)
54+
editor.scrollToBufferPosition(pos)
55+
editor.setCursorBufferPosition(pos)
5356
} else {
5457
atom.notifications.addError('Julia-Client: Format-Code', {
5558
description: 'Cancelled the formatting task because the selected code has been manually modified.',

0 commit comments

Comments
 (0)