comply with vim behavior
This commit is contained in:
parent
2cafba248c
commit
66e5f697f6
2 changed files with 26 additions and 21 deletions
|
|
@ -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}")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
else
|
||||||
atom.workspace.getActivePane().saveActiveItemAs(nextAction)
|
editor.save()
|
||||||
w: => @write()
|
else
|
||||||
wq: =>
|
if filePath?
|
||||||
@write(close=true)
|
editor.saveAs(path.join(projectPath, filePath))
|
||||||
|
else
|
||||||
|
pane.saveActiveItemAs()
|
||||||
|
w: (filePath) => @write(filePath)
|
||||||
|
|
||||||
module.exports = Ex
|
module.exports = Ex
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue