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

Commit

Permalink
restore cursor position after fix command
Browse files Browse the repository at this point in the history
  • Loading branch information
yacut committed Mar 17, 2017
1 parent e37cca9 commit a3441a5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,15 @@ module.exports = {
rules = ignoredRulesWhenFixing;
}

const cursorPosition = editor.getCursorBufferPosition();
this.worker.request('job', {
type: 'fix',
config: atom.config.get('linter-eslint'),
rules,
filePath,
projectPath
}).then(() => {
editor.setCursorBufferPosition(cursorPosition);
}).catch(err => {
atom.notifications.addWarning(err.message);
});
Expand Down Expand Up @@ -114,13 +117,16 @@ module.exports = {
rules = ignoredRulesWhenFixing;
}

const cursorPosition = textEditor.getCursorBufferPosition();
this.worker.request('job', {
type: 'fix',
config: atom.config.get('linter-eslint'),
rules,
filePath,
projectPath
}).then(response => atom.notifications.addSuccess(response)).catch(err => {
}).then(response => atom.notifications.addSuccess(response)).then(() => {
textEditor.setCursorBufferPosition(cursorPosition);
}).catch(err => {
atom.notifications.addWarning(err.message);
});
}
Expand Down
8 changes: 7 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@ module.exports = {
rules = ignoredRulesWhenFixing
}

const cursorPosition = editor.getCursorBufferPosition()
this.worker.request('job', {
type: 'fix',
config: atom.config.get('linter-eslint'),
rules,
filePath,
projectPath
}).then(() => {
editor.setCursorBufferPosition(cursorPosition)
}).catch((err) => {
atom.notifications.addWarning(err.message)
})
Expand Down Expand Up @@ -104,6 +107,7 @@ module.exports = {
rules = ignoredRulesWhenFixing
}

const cursorPosition = textEditor.getCursorBufferPosition()
this.worker.request('job', {
type: 'fix',
config: atom.config.get('linter-eslint'),
Expand All @@ -112,7 +116,9 @@ module.exports = {
projectPath
}).then(response =>
atom.notifications.addSuccess(response)
).catch((err) => {
).then(() => {
textEditor.setCursorBufferPosition(cursorPosition)
}).catch((err) => {
atom.notifications.addWarning(err.message)
})
}
Expand Down

0 comments on commit a3441a5

Please sign in to comment.