diff --git a/src/git-repository-async.js b/src/git-repository-async.js index dad54fe03..f1a7217bb 100644 --- a/src/git-repository-async.js +++ b/src/git-repository-async.js @@ -677,17 +677,16 @@ export default class GitRepositoryAsync { // ======= checkoutHeadForEditor (editor) { - return new Promise((resolve, reject) => { - const filePath = editor.getPath() - if (filePath) { - if (editor.buffer.isModified()) { - editor.buffer.reload() - } - resolve(filePath) - } else { - reject() - } - }).then(filePath => this.checkoutHead(filePath)) + const filePath = editor.getPath() + if (!filePath) { + return Promise.reject() + } + + if (editor.buffer.isModified()) { + editor.buffer.reload() + } + + return this.checkoutHead(filePath) } // Create a new branch with the given name.