From 1229c28de01829d12ff31addd927c2025d327f22 Mon Sep 17 00:00:00 2001 From: yacut Date: Mon, 20 Mar 2017 21:36:43 +0100 Subject: [PATCH] 853 add some comments to explain the issue --- src/main.js | 6 ++++++ 1 file changed, 6 insertions(+) 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)