From a7d46e443572ac4a416a0793fbeac6e4d90132bf Mon Sep 17 00:00:00 2001 From: joshaber Date: Mon, 11 Jan 2016 21:36:33 -0500 Subject: [PATCH] Capture less in .checkoutHeadForEditor. --- src/git-repository-async.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) 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.