Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
853 add some comments to explain the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
yacut committed Mar 20, 2017
1 parent a3441a5 commit 1229c28
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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)
Expand Down Expand Up @@ -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',
Expand All @@ -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)
Expand Down

0 comments on commit 1229c28

Please sign in to comment.