diff --git a/lib/ex.coffee b/lib/ex.coffee index ca0ca0e..be1ba80 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -112,8 +112,13 @@ class Ex quit: -> atom.workspace.getActivePane().destroyActiveItem() + quitall: -> + atom.close() + q: => @quit() + qall: => @quitall() + tabedit: (args) => if args.args.trim() isnt '' @edit(args) @@ -216,20 +221,37 @@ class Ex deferred.promise + wall: -> + atom.workspace.saveAll() + w: (args) => @write(args) wq: (args) => @write(args).then => @quit() + wa: => + @wall() + + wqall: => + @wall() + @quitall() + + wqa: => + @wqall() + + xall: => + @wqall() + + xa: => + @wqall() + saveas: (args) => args.saveas = true @write(args) xit: (args) => @wq(args) - wa: -> - atom.workspace.saveAll() split: ({ range, args }) -> args = args.trim() diff --git a/spec/ex-commands-spec.coffee b/spec/ex-commands-spec.coffee index 35bfd22..b1b0201 100644 --- a/spec/ex-commands-spec.coffee +++ b/spec/ex-commands-spec.coffee @@ -162,6 +162,13 @@ describe "the commands", -> expect(atom.notifications.notifications).toEqual([]) expect(fs.readFileSync(existsPath, 'utf-8')).toEqual('abc\ndef') + describe ":wall", -> + it "saves all", -> + spyOn(atom.workspace, 'saveAll') + keydown(':') + submitNormalModeInputText('wall') + expect(atom.workspace.saveAll).toHaveBeenCalled() + describe ":saveas", -> describe "when editing a new file", -> beforeEach -> @@ -288,6 +295,13 @@ describe "the commands", -> submitNormalModeInputText('quit') expect(pane.promptToSaveItem).toHaveBeenCalled() + describe ":quitall", -> + it "closes Atom", -> + spyOn(atom, 'close') + keydown(':') + submitNormalModeInputText('quitall') + expect(atom.close).toHaveBeenCalled() + describe ":tabclose", -> it "acts as an alias to :quit", -> spyOn(Ex, 'tabclose').andCallThrough() @@ -376,6 +390,15 @@ describe "the commands", -> submitNormalModeInputText('xit') expect(Ex.wq).toHaveBeenCalled() + describe ":wqall", -> + it "calls :wall, then :quitall", -> + spyOn(Ex, 'wall') + spyOn(Ex, 'quitall') + keydown(':') + submitNormalModeInputText('wqall') + expect(Ex.wall).toHaveBeenCalled() + expect(Ex.quitall).toHaveBeenCalled() + describe ":edit", -> describe "without a file name", -> it "reloads the file from the disk", ->