From 0b2af222027c4771ba2978430663960547513030 Mon Sep 17 00:00:00 2001 From: Dave de Fijter Date: Mon, 23 Feb 2015 10:14:43 +0100 Subject: [PATCH] added search and used promises for wq --- lib/ex.coffee | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/ex.coffee b/lib/ex.coffee index f5e066c..d565a83 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -1,30 +1,35 @@ class Ex quit: -> atom.workspace.getActivePane().destroyActiveItem() + q: => @quit() + + s: -> + setTimeout(-> + atom.commands.dispatch(atom.views.getView(atom.workspace.getActiveEditor()), 'find-and-replace:show') + , 100) # Timeout is for working around issue where the search area doesn't focus + tabedit: (filenames) -> if filenames? and filenames.length > 0 atom.open(pathsToOpen: filenames) else atom.open() + tabe: (filenames) => @tabedit(filenames) - write: (close=false) => - if close - nextAction = -> - atom.notifications.addSuccess("Saved and closed") - atom.workspace.getActivePane().destroyActiveItem() - else - nextAction = -> - atom.notifications.addSuccess("Saved") + + write: () => + dfd = Promise.defer() if atom.workspace.getActiveTextEditor().getPath() isnt undefined - atom.workspace.getActivePane().saveItem(atom.workspace.getActivePane().getActiveItem(), nextAction) + atom.workspace.getActivePane().saveItem(atom.workspace.getActivePane().getActiveItem(), dfd.resolve) else - atom.workspace.getActivePane().saveActiveItemAs(nextAction) + atom.workspace.getActivePane().saveActiveItemAs(dfd.resolve) + + dfd.promise + w: => @write() - wq: => - @write(close=true) + wq: => @write().then(=>@quit()) module.exports = Ex