diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..31132f0 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,29 @@ +# Ex-Mode Contributing Guidelines + +Current Maintainers: + +- [@jazzpi](https://github.com/jazzpi) +- [@LongLiveCHIEF](https://github.com/LongLiveCHIEF) + +This project is accepting new maintainers. Interested parties should + +1. Open a new issue, titled: `New Maintainer Request` +2. Assign the issue to [@lloeki](https://github.com/lloeki) +3. The last line of your request should `/cc @jazzpi @LongLiveCHIEF` + +## Pull Requests + +- If the PR *fixes* or should result in the closure of any issues, use the `fixes #` or `closes #` syntax to ensure issue will +close when your PR is merged +- All pull-requests that fix a bug or add a new feature *must* have accompanying tests before they will be merged. If you want +to speed up the merge of your PR, please contribute these tests + - *note*: if you submit a PR but are unsure how to write tests, please begin your PR title with `[needs tests]` +- Please use the [pull request template](PULL_REQUEST_TEMPLATE.md) as a guide for submitting your PR. +- Include a `/cc` for @LongLiveCHIEF and @jazzpi the current maintainers + +## Issues + +- Be aware of the responsibilities of `ex-mode` vs `vim-mode` +- If you have identified a bug we would welcome any Pull Requests that either: + - Fix the issue + - Create failing tests to confirm the bug diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ae22d79 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,14 @@ +Fixes # . + +Changes Proposed in this Pull Request: +- +- +- + +I have written tests for: + +- [ ] New features introduced +- [ ] Bugs fixed +- [ ] Neither (I'm just enhancing tests!) + +@jazzpi @LongLiveCHIEF diff --git a/lib/ex-mode.coffee b/lib/ex-mode.coffee index e3a15b2..490003e 100644 --- a/lib/ex-mode.coffee +++ b/lib/ex-mode.coffee @@ -35,3 +35,15 @@ module.exports = ExMode = consumeVim: (vim) -> @vim = vim @globalExState.setVim(vim) + + config: + splitbelow: + title: 'Split below' + description: 'when splitting, split from below' + type: 'boolean' + default: 'false' + splitright: + title: 'Split right' + description: 'when splitting, split from right' + type: 'boolean' + default: 'false' diff --git a/lib/ex.coffee b/lib/ex.coffee index 41aaed6..c91beb7 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -127,11 +127,11 @@ class Ex tabe: (args) => @tabedit(args) - tabnew: ({ range, args }) => - if args.trim() is '' + tabnew: (args) => + if args.args.trim() is '' atom.workspace.open() else - @tabedit(range, args) + @tabedit(args) tabclose: (args) => @quit(args) @@ -258,13 +258,23 @@ class Ex filePaths = args.split(' ') filePaths = undefined if filePaths.length is 1 and filePaths[0] is '' pane = atom.workspace.getActivePane() - if filePaths? and filePaths.length > 0 - newPane = pane.splitUp() - for file in filePaths - do -> - atom.workspace.openURIInPane file, newPane + if atom.config.get('ex-mode.splitbelow') + if filePaths? and filePaths.length > 0 + newPane = pane.splitDown() + for file in filePaths + do -> + atom.workspace.openURIInPane file, newPane + else + pane.splitDown(copyActiveItem: true) else - pane.splitUp(copyActiveItem: true) + if filePaths? and filePaths.length > 0 + newPane = pane.splitUp() + for file in filePaths + do -> + atom.workspace.openURIInPane file, newPane + else + pane.splitUp(copyActiveItem: true) + sp: (args) => @split(args) @@ -335,13 +345,22 @@ class Ex filePaths = args.split(' ') filePaths = undefined if filePaths.length is 1 and filePaths[0] is '' pane = atom.workspace.getActivePane() - if filePaths? and filePaths.length > 0 - newPane = pane.splitLeft() - for file in filePaths - do -> - atom.workspace.openURIInPane file, newPane + if atom.config.get('ex-mode.splitright') + if filePaths? and filePaths.length > 0 + newPane = pane.splitRight() + for file in filePaths + do -> + atom.workspace.openURIInPane file, newPane + else + pane.splitRight(copyActiveItem: true) else - pane.splitLeft(copyActiveItem: true) + if filePaths? and filePaths.length > 0 + newPane = pane.splitLeft() + for file in filePaths + do -> + atom.workspace.openURIInPane file, newPane + else + pane.splitLeft(copyActiveItem: true) vsp: (args) => @vsplit(args) diff --git a/spec/ex-commands-spec.coffee b/spec/ex-commands-spec.coffee index 2fa05c5..08237e3 100644 --- a/spec/ex-commands-spec.coffee +++ b/spec/ex-commands-spec.coffee @@ -496,27 +496,52 @@ describe "the commands", -> submitNormalModeInputText('tabnew') expect(atom.workspace.open).toHaveBeenCalled() - describe ":split", -> - it "splits the current file upwards", -> - pane = atom.workspace.getActivePane() - spyOn(pane, 'splitUp').andCallThrough() - filePath = projectPath('split') - editor.saveAs(filePath) + it "opens a new tab for editing when provided an argument", -> + spyOn(Ex, 'tabnew').andCallThrough() + spyOn(Ex, 'tabedit') keydown(':') - submitNormalModeInputText('split') - expect(pane.splitUp).toHaveBeenCalled() + submitNormalModeInputText('tabnew tabnew-test') + expect(Ex.tabedit) + .toHaveBeenCalledWith(Ex.tabnew.calls[0].args...) + + describe ":split", -> + it "splits the current file upwards/downward", -> + pane = atom.workspace.getActivePane() + if atom.config.get('ex-mode.splitbelow') + spyOn(pane, 'splitDown').andCallThrough() + filePath = projectPath('split') + editor.saveAs(filePath) + keydown(':') + submitNormalModeInputText('split') + expect(pane.splitDown).toHaveBeenCalled() + else + spyOn(pane, 'splitUp').andCallThrough() + filePath = projectPath('split') + editor.saveAs(filePath) + keydown(':') + submitNormalModeInputText('split') + expect(pane.splitUp).toHaveBeenCalled() # FIXME: Should test whether the new pane contains a TextEditor # pointing to the same path describe ":vsplit", -> - it "splits the current file to the left", -> - pane = atom.workspace.getActivePane() - spyOn(pane, 'splitLeft').andCallThrough() - filePath = projectPath('vsplit') - editor.saveAs(filePath) - keydown(':') - submitNormalModeInputText('vsplit') - expect(pane.splitLeft).toHaveBeenCalled() + it "splits the current file to the left/right", -> + if atom.config.get('ex-mode.splitright') + pane = atom.workspace.getActivePane() + spyOn(pane, 'splitRight').andCallThrough() + filePath = projectPath('vsplit') + editor.saveAs(filePath) + keydown(':') + submitNormalModeInputText('vsplit') + expect(pane.splitLeft).toHaveBeenCalled() + else + pane = atom.workspace.getActivePane() + spyOn(pane, 'splitLeft').andCallThrough() + filePath = projectPath('vsplit') + editor.saveAs(filePath) + keydown(':') + submitNormalModeInputText('vsplit') + expect(pane.splitLeft).toHaveBeenCalled() # FIXME: Should test whether the new pane contains a TextEditor # pointing to the same path