From 47963ef2e531689c0823e57ebf5409665c5b29b7 Mon Sep 17 00:00:00 2001 From: Wliu <50Wliu@users.noreply.github.com> Date: Fri, 17 Nov 2017 23:32:53 +0100 Subject: [PATCH] And test it with editor:checkout-head-revision --- src/workspace.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/workspace.js b/src/workspace.js index defb43df0..8de7adc65 100644 --- a/src/workspace.js +++ b/src/workspace.js @@ -1990,25 +1990,22 @@ module.exports = class Workspace extends Model { checkoutHeadRevision (editor) { if (editor.getPath()) { - const checkoutHead = () => { - return this.project.repositoryForDirectory(new Directory(editor.getDirectoryPath())) - .then(repository => repository && repository.checkoutHeadForEditor(editor)) + const checkoutHead = async () => { + const repository = await this.project.repositoryForDirectory(new Directory(editor.getDirectoryPath())) + if (repository) repository.checkoutHeadForEditor(editor) } if (this.config.get('editor.confirmCheckoutHeadRevision')) { this.applicationDelegate.confirm({ message: 'Confirm Checkout HEAD Revision', detailedMessage: `Are you sure you want to discard all changes to "${editor.getFileName()}" since the last Git commit?`, - buttons: { - OK: checkoutHead, - Cancel: null - } + buttons: ['OK', 'Cancel'] + }, response => { + if (response === 0) checkoutHead() }) } else { - return checkoutHead() + checkoutHead() } - } else { - return Promise.resolve(false) } } }