added search and used promises for wq

This commit is contained in:
Dave de Fijter 2015-02-23 10:14:43 +01:00
parent 2cafba248c
commit 0b2af22202

View file

@ -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