comply with vim behavior

This commit is contained in:
Loic Nageleisen 2015-02-23 10:44:51 +01:00
parent 2cafba248c
commit 66e5f697f6
2 changed files with 26 additions and 21 deletions

View file

@ -15,7 +15,7 @@ class Command
func = (new Ex)[command] func = (new Ex)[command]
if func? if func?
func(args) func(args...)
else else
throw new CommandError("#{input.characters}") throw new CommandError("#{input.characters}")

View file

@ -1,30 +1,35 @@
path = require 'path'
class Ex class Ex
quit: -> quit: ->
atom.workspace.getActivePane().destroyActiveItem() atom.workspace.getActivePane().destroyActiveItem()
q: => q: =>
@quit() @quit()
tabedit: (filenames) -> tabedit: (filePaths...) ->
if filenames? and filenames.length > 0 pane = atom.workspace.getActivePane()
atom.open(pathsToOpen: filenames) if filePaths? and filePaths.length > 0
for file in filePaths
do -> atom.workspace.openURIInPane file, pane
else else
atom.open() atom.workspace.openURIInPane('', pane)
tabe: (filenames) => tabe: (filePaths...) =>
@tabedit(filenames) @tabedit(filePaths...)
write: (close=false) => write: (filePath) =>
if close projectPath = atom.project.getPath()
nextAction = -> pane = atom.workspace.getActivePane()
atom.notifications.addSuccess("Saved and closed") editor = atom.workspace.getActiveEditor()
atom.workspace.getActivePane().destroyActiveItem()
else
nextAction = ->
atom.notifications.addSuccess("Saved")
if atom.workspace.getActiveTextEditor().getPath() isnt undefined if atom.workspace.getActiveTextEditor().getPath() isnt undefined
atom.workspace.getActivePane().saveItem(atom.workspace.getActivePane().getActiveItem(), nextAction) if filePath?
editorPath = editor.getPath()
editor.saveAs(path.join(projectPath, filePath))
editor.buffer.setPath(editorPath)
else
editor.save()
else else
atom.workspace.getActivePane().saveActiveItemAs(nextAction) if filePath?
w: => @write() editor.saveAs(path.join(projectPath, filePath))
wq: => else
@write(close=true) pane.saveActiveItemAs()
w: (filePath) => @write(filePath)
module.exports = Ex module.exports = Ex