diff --git a/src/main.js b/src/main.js index 2dfb3139..3ae9caa5 100644 --- a/src/main.js +++ b/src/main.js @@ -66,6 +66,8 @@ module.exports = { rules = ignoredRulesWhenFixing } + // The fix replaces the file content and the cursor jumps automatically + // to the beginning of the file, so save current cursor position const cursorPosition = editor.getCursorBufferPosition() this.worker.request('job', { type: 'fix', @@ -74,6 +76,7 @@ module.exports = { filePath, projectPath }).then(() => { + // set cursor to the position before fix job editor.setCursorBufferPosition(cursorPosition) }).catch((err) => { atom.notifications.addWarning(err.message) @@ -107,6 +110,8 @@ module.exports = { rules = ignoredRulesWhenFixing } + // The fix replaces the file content and the cursor jumps automatically + // to the beginning of the file, so save current cursor position const cursorPosition = textEditor.getCursorBufferPosition() this.worker.request('job', { type: 'fix', @@ -117,6 +122,7 @@ module.exports = { }).then(response => atom.notifications.addSuccess(response) ).then(() => { + // set cursor to the position before fix job textEditor.setCursorBufferPosition(cursorPosition) }).catch((err) => { atom.notifications.addWarning(err.message)