diff options
| author | Ben Beltran <ben@nsovocal.com> | 2015-07-10 11:12:25 -0500 |
|---|---|---|
| committer | Ben Beltran <ben@nsovocal.com> | 2015-07-10 11:12:25 -0500 |
| commit | 24c7594d62d8d7fbbcdb64b11ce4adc5d8e6991a (patch) | |
| tree | ded312222bb108923da1820ba40b04d710d20e5b /atom/packages/vim-surround | |
| parent | eb786e82d170e2abc351a432ade616d6ecdeeb6b (diff) | |
Adds atom
Diffstat (limited to 'atom/packages/vim-surround')
| -rw-r--r-- | atom/packages/vim-surround/.npmignore | 3 | ||||
| -rw-r--r-- | atom/packages/vim-surround/.travis.yml | 11 | ||||
| -rw-r--r-- | atom/packages/vim-surround/CHANGELOG.md | 50 | ||||
| -rw-r--r-- | atom/packages/vim-surround/LICENSE.md | 20 | ||||
| -rw-r--r-- | atom/packages/vim-surround/README.md | 117 | ||||
| -rw-r--r-- | atom/packages/vim-surround/keymaps/surround.cson | 7 | ||||
| -rw-r--r-- | atom/packages/vim-surround/lib/command/base.coffee | 59 | ||||
| -rw-r--r-- | atom/packages/vim-surround/lib/command/change.coffee | 74 | ||||
| -rw-r--r-- | atom/packages/vim-surround/lib/command/delete.coffee | 33 | ||||
| -rw-r--r-- | atom/packages/vim-surround/lib/command/selector.coffee | 22 | ||||
| -rw-r--r-- | atom/packages/vim-surround/lib/command/surround.coffee | 18 | ||||
| -rw-r--r-- | atom/packages/vim-surround/lib/vim-surround.coffee | 41 | ||||
| -rw-r--r-- | atom/packages/vim-surround/package.json | 51 | ||||
| -rw-r--r-- | atom/packages/vim-surround/spec/spec-helper.coffee | 13 | ||||
| -rw-r--r-- | atom/packages/vim-surround/spec/vim-surround-spec.coffee | 72 |
15 files changed, 591 insertions, 0 deletions
diff --git a/atom/packages/vim-surround/.npmignore b/atom/packages/vim-surround/.npmignore new file mode 100644 index 0000000..ade14b9 --- /dev/null +++ b/atom/packages/vim-surround/.npmignore @@ -0,0 +1,3 @@ +.DS_Store +npm-debug.log +node_modules diff --git a/atom/packages/vim-surround/.travis.yml b/atom/packages/vim-surround/.travis.yml new file mode 100644 index 0000000..d73c8e2 --- /dev/null +++ b/atom/packages/vim-surround/.travis.yml @@ -0,0 +1,11 @@ +language: objective-c + +notifications: + email: + on_success: never + on_failure: change + +script: 'curl -s https://raw.githubusercontent.com/atom/ci/master/build-package.sh | sh' + +git: + depth: 10 diff --git a/atom/packages/vim-surround/CHANGELOG.md b/atom/packages/vim-surround/CHANGELOG.md new file mode 100644 index 0000000..c669642 --- /dev/null +++ b/atom/packages/vim-surround/CHANGELOG.md @@ -0,0 +1,50 @@ +## 0.7.1 +* Propagate README changes. + +## 0.7.0 +* Change surround and delete surround implemented. Thanks to @shemerey :D ! + +## 0.6.1 +* Fixed keymap -> keymaps change. [vim-surround #19](https://github.com/gepoch/vim-surround/issues/19) + +## 0.6.0 +* Upgraded to new config schema. General restructuring. + +## 0.5.1 +* Handle undefined values in config. + +## 0.5.0 +* Configurable surround key to support muscle memory in response to [vim-surround #12](https://github.com/gepoch/vim-surround/issues/12) + +## 0.4.3 +* Fixed bug [vim-surround #13](https://github.com/gepoch/vim-surround/issues/13) + + +## 0.4.2 +* Fixed bug [vim-surround #11](https://github.com/gepoch/vim-surround/issues/11) +* Readme updates. + +## 0.4.1 +* Renamed the dynamic keybindings to match the package name. +* Added some tests. +* Poked the README. + +## 0.4.0 +* Multiple cursor support. + +## 0.3.0 +* Updated for Atom API v1.0.0 changes. + +## 0.2.3 +* Fixed bug: [vim-surround #5](https://github.com/gepoch/vim-surround/issues/5) + +## 0.2.0 - Activation and Keybindings Improved. +* Keybindings are now dynamically generated from the configured pairs. No more + user keybindings changes necessary! +* Activation is now on atom boot since keybindings are now dynamic and + impossible to predict for the purposes of activation events. +* Fixed bug where surround action did not exit visual mode. + +## 0.1.0 - First Release +* Every feature added +* Every bug fixed diff --git a/atom/packages/vim-surround/LICENSE.md b/atom/packages/vim-surround/LICENSE.md new file mode 100644 index 0000000..9e77889 --- /dev/null +++ b/atom/packages/vim-surround/LICENSE.md @@ -0,0 +1,20 @@ +Copyright (c) 2014 George Marchin + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/atom/packages/vim-surround/README.md b/atom/packages/vim-surround/README.md new file mode 100644 index 0000000..193f733 --- /dev/null +++ b/atom/packages/vim-surround/README.md @@ -0,0 +1,117 @@ +# Vim Surround for Atom [](https://travis-ci.org/gepoch/vim-surround) + +Surround is an implementation of vim-surround for the [atom](http://atom.io) +editor, creating a vim-surround with the power of Atom! + +You should definitely have [vim-mode](https://atom.io/packages/vim-mode) for +this package to function properly, of course. + +Inspiration from and kudos to the wonderful [vim-surround for +vim](https://github.com/tpope/vim-surround) + +See vim-surround on [github](https://github.com/gepoch/vim-surround) or +[atom.io](https://atom.io/packages/vim-surround). + +## News + +* This package supports visual mode's `s )` set of commands for a configurable + set of pairs. + +* Next on the roadmap are pair deletions with `d )` and friends. + +* New in 0.4: Multiple cursors are now supported, and conveniently work just + like you think they do. + +* New in 0.5: Stable configuration changes and configurable surround key! + +* New in 0.7: Change surround and delete surround added. + +### Muscle Memory Compatability Note + +vim-surround uses a lowercase `s` instead of `S` for surround commands! This is +configurable in the package settings, if you would like to set it to the +original keybinding. + +## How to use Surround + +### Surrounding + +For double quotes, highlight the string in visual mode and enter `s "`. + +``` +Hello world -> "Hello world" +``` + +For parentheses there are two options. `s )` will surround as normal. `s (` +will pad with a space. All asymmetrical pairs have the secondary space-padded +form. + +For example: + +`s )` + +``` +Hello world -> (Hello world) +``` + +`s (` + +``` +Hello world -> ( Hello world ) +``` + +### Changing Surrounding Pairs + +Suppose I want to make double quotes into single quotes. To do this, I should +put my cursor inside the double quotes in question and enter `c s " '` + +``` +"Hello world" -> 'Hello world' +``` + +### Deleting Surrounding Pairs + +To delete the single quotes, place your cursor inside of them and enter `d s '` + +``` +'Hello world' -> Hello world +``` +### Configuration + +Currently, the following pairs work out of the box!: + +- () +- [] +- {} +- "" +- '' + +You can add to the available pairs in atom's settings, and the commands will +be dynamically added to your keybindings. + +For example if I'm working on Jinja templates, and I want to add the ability to +surround using `{%` and `%}` I would add this in my settings: + +``` +(), [], {}, "", '', {%%} +``` + +Then: + +`s % }` + +``` +Hello world -> {%Hello world%} +``` + +`s { %` + +``` +Hello world -> {% Hello world %} +``` + +### TODO + +- [x] Implement deleting surrounding pairs with `d s` +- [x] Implement changing surrounding pairs with `c s` +- [ ] Intelligent tag surrounding/deleting/replacing with `s <q>` and friends. diff --git a/atom/packages/vim-surround/keymaps/surround.cson b/atom/packages/vim-surround/keymaps/surround.cson new file mode 100644 index 0000000..5de6766 --- /dev/null +++ b/atom/packages/vim-surround/keymaps/surround.cson @@ -0,0 +1,7 @@ +# OOPS! Good job with your dilligent hunting, but vim-surround's keybindings +# are actually completely dynamic, so it doesn't use this file.... So I'll use +# this as a guest book. Send me a PR! + +# # OFFICIAL VIM-SURROUND GUEST BOOK :+1: + +# George Marchin ~ Hi Mom! diff --git a/atom/packages/vim-surround/lib/command/base.coffee b/atom/packages/vim-surround/lib/command/base.coffee new file mode 100644 index 0000000..b40e644 --- /dev/null +++ b/atom/packages/vim-surround/lib/command/base.coffee @@ -0,0 +1,59 @@ +{CompositeDisposable} = require 'atom' + +module.exports = class Base + + constructor: (config) -> + @disposables = new CompositeDisposable + + @curPairs = [] + @registerPairs config.pairs + + registerPairs: (pairs) -> + pairs = (x for x in pairs when x.length > 0 and x.length %2 == 0) + + for pair in pairs + if pair not in @curPairs + @registerPair pair + @curPairs.push(pair) + + registerPair: (pair) -> + [left, right] = @splitPair(pair) + + if left != right + @createPairBindings left, "#{left} ", " #{right}" + @createPairBindings right, left, right + + createPairBindings: (key, left, right) -> + name = "vim-surround:#{@getName key}" + + # First, we add a command to the system to actually perform the surround. + # We attach the disposable to our object's list. + @disposables.add atom.commands.add @context, name, @getRunner left, right + + # Next, we build up keybindings for our command. First, we build a + # space-delineated version of our key that's passed in. This breaks up + # double keys like `{%` into the seperate keystroke form: `{ %` + keys = "" + for i in [0..key.length-1] + if i == 0 + keys = key[i] + else + keys = "#{keys} #{key[i]}" + + # Making a one-command keymap data structure here. Basically: + # "atom-text-editor.vim-mode.visual-mode": + # "s (": + # "vim-surround:surround-(" + + keymapArg = {} + fullCommand = "#{@command} #{keys}" + keymapArg[fullCommand] = name + + contextArg = {} + contextArg[@context] = keymapArg + + # Capture the disposable heretom test! + @disposables.add atom.keymaps.add name, contextArg + + splitPair: (pair) -> + return [pair[..(pair.length/2)-1], pair[pair.length/2..]] diff --git a/atom/packages/vim-surround/lib/command/change.coffee b/atom/packages/vim-surround/lib/command/change.coffee new file mode 100644 index 0000000..b1860f5 --- /dev/null +++ b/atom/packages/vim-surround/lib/command/change.coffee @@ -0,0 +1,74 @@ +{CompositeDisposable} = require 'atom' + +Base = require './base' +Selector = require './selector' + +module.exports = class Change + constructor: (config) -> + @command = config.changeSurroundCommand + @context = "atom-text-editor.vim-mode.command-mode" + @disposables = new CompositeDisposable + @curPairs = [] + @curPairsWithTarget = [] + @registerPairs config.pairs + + getName: (key, targetKey) -> "change-#{key}-to-#{targetKey}" + + registerPairs: (pairs) -> + pairs = (x for x in pairs when x.length > 0 and x.length %2 == 0) + + for pair in pairs + for target in pairs + if "#{pair}#{target}" not in @curPairs + @registerPair pair, target + @curPairs.push("#{pair}#{target}") + + registerPair: (pair, target) -> + [left, right] = @splitPair(pair) + [target_left, target_right] = @splitPair(target) + + for key in [left, right] + for targetKey in [target_left, target_right] + if "#{key}#{targetKey}" not in @curPairsWithTarget + name = "vim-surround:#{@getName(key, targetKey)}" + + unless pair == target + @disposables.add atom.commands.add @context, name, @getRunner pair, target + + keymapArg = {} + fullCommand = "#{@command} #{key} #{targetKey}" + keymapArg[fullCommand] = name + + contextArg = {} + contextArg[@context] = keymapArg + + # Capture the disposable heretom test! + unless pair == target + @disposables.add atom.keymaps.add name, contextArg + @curPairsWithTarget.push("#{key}#{targetKey}") + + splitPair: (pair) -> + return [pair[..(pair.length/2)-1], pair[pair.length/2..]] + + getRunner: (from, to) -> -> + [left, right] = [from[0], from[1]] + [target_left, target_right] = [to[0], to[1]] + editor = atom.workspace.getActiveTextEditor() + selector = new Selector(editor, left, right) + + editor.transact -> + cursorPos = editor.getCursorBufferPosition() + + selector.inside().select() + editor.selections.forEach (selection) -> + text = selection.getText() + + # restore cursore and select text with surrounding keys + editor.setCursorBufferPosition(cursorPos) + selector.outside().select() + + editor.selections.forEach (selection) -> + selection.insertText "#{target_left}#{text}#{target_right}" + + # restore cursore + editor.setCursorBufferPosition(cursorPos) diff --git a/atom/packages/vim-surround/lib/command/delete.coffee b/atom/packages/vim-surround/lib/command/delete.coffee new file mode 100644 index 0000000..aa5eec0 --- /dev/null +++ b/atom/packages/vim-surround/lib/command/delete.coffee @@ -0,0 +1,33 @@ +{CompositeDisposable} = require 'atom' + +Base = require './base' +Selector = require './selector' + +module.exports = class Delete extends Base + constructor: (config) -> + @command = config.deleteSurroundCommand + @context = "atom-text-editor.vim-mode.command-mode" + super config + + getName: (key) -> "delete-#{key}" + + getRunner: (left, right) -> -> + editor = atom.workspace.getActiveTextEditor() + selector = new Selector(editor, left, right) + + editor.transact -> + cursorPos = editor.getCursorBufferPosition() + + selector.inside().select() + editor.selections.forEach (selection) -> + text = selection.getText() + + # restore cursore and select text with surrounding keys + editor.setCursorBufferPosition(cursorPos) + selector.outside().select() + + editor.selections.forEach (selection) -> + selection.insertText text + + # restore cursore + editor.setCursorBufferPosition(cursorPos) diff --git a/atom/packages/vim-surround/lib/command/selector.coffee b/atom/packages/vim-surround/lib/command/selector.coffee new file mode 100644 index 0000000..aae3541 --- /dev/null +++ b/atom/packages/vim-surround/lib/command/selector.coffee @@ -0,0 +1,22 @@ +vimModePath = atom.packages.resolvePackagePath('vim-mode') +{SelectInsideQuotes, SelectInsideBrackets} = require "#{vimModePath}/lib/text-objects" + +module.exports = class Selector + constructor: (@editor, left, right) -> + @left = left.trim() + @right = right.trim() + + inside: -> + if @isBraket() + new SelectInsideBrackets(@editor, @left, @right, false) + else + new SelectInsideQuotes(@editor, @left, false) + + outside: -> + if @isBraket() + new SelectInsideBrackets(@editor, @left, @right, true) + else + new SelectInsideQuotes(@editor, @left, true) + + isBraket: -> + ['[', ']', '{', '}', '<', '>', '(', ')'].indexOf?(@left.trim()) >= 0 diff --git a/atom/packages/vim-surround/lib/command/surround.coffee b/atom/packages/vim-surround/lib/command/surround.coffee new file mode 100644 index 0000000..e939f78 --- /dev/null +++ b/atom/packages/vim-surround/lib/command/surround.coffee @@ -0,0 +1,18 @@ +{CompositeDisposable} = require 'atom' + +Base = require './base' + +module.exports = class Surround extends Base + constructor: (config) -> + @command = config.surroundCommand + @context = "atom-text-editor.vim-mode.visual-mode" + super config + + getName: (key) -> "surround-#{key}" + + getRunner: (left, right) -> -> + editor = atom.workspace.getActiveTextEditor() + editor.transact -> + editor.selections.forEach (selection) -> + text = selection.getText() + selection.insertText "#{left}#{text}#{right}" diff --git a/atom/packages/vim-surround/lib/vim-surround.coffee b/atom/packages/vim-surround/lib/vim-surround.coffee new file mode 100644 index 0000000..b9fd332 --- /dev/null +++ b/atom/packages/vim-surround/lib/vim-surround.coffee @@ -0,0 +1,41 @@ +{CompositeDisposable} = require 'atom' + +Surround = require './command/surround' +Delete = require './command/delete' +Change = require './command/change' + +module.exports = + config: + pairs: + type: 'array' + default: ['()', '{}', '[]', '""', "''"] + items: + type: 'string' + changeSurroundCommand: + type: 'string' + default: 'c s' + deleteSurroundCommand: + type: 'string' + default: 'd s' + surroundCommand: + type: 'string' + default: 's' + + activate: (state) -> + @commandClasses = [ + Surround, Delete, Change + ] + + @configLoop = atom.config.observe 'vim-surround', (config) => + @disposables.dispose() if @disposables? + @disposables = new CompositeDisposable + + @commands = [] + + for cls in @commandClasses + command = new cls config + @commands.push command + @disposables.add command.disposables + + deactivate: () -> + @disposables.dispose() diff --git a/atom/packages/vim-surround/package.json b/atom/packages/vim-surround/package.json new file mode 100644 index 0000000..ead55b9 --- /dev/null +++ b/atom/packages/vim-surround/package.json @@ -0,0 +1,51 @@ +{ + "name": "vim-surround", + "main": "./lib/vim-surround", + "version": "0.7.2", + "description": "vim-surround for Atom!", + "repository": { + "type": "git", + "url": "https://github.com/gepoch/vim-surround" + }, + "license": "MIT", + "keywords": [ + "pair", + "parentheses", + "quotes", + "surround", + "vim" + ], + "engines": { + "atom": ">0.50.0" + }, + "dependencies": {}, + "consumedServices": {}, + "readme": "# Vim Surround for Atom [](https://travis-ci.org/gepoch/vim-surround)\n\nSurround is an implementation of vim-surround for the [atom](http://atom.io)\neditor, creating a vim-surround with the power of Atom!\n\nYou should definitely have [vim-mode](https://atom.io/packages/vim-mode) for\nthis package to function properly, of course.\n\nInspiration from and kudos to the wonderful [vim-surround for\nvim](https://github.com/tpope/vim-surround)\n\nSee vim-surround on [github](https://github.com/gepoch/vim-surround) or\n[atom.io](https://atom.io/packages/vim-surround).\n\n## News\n\n* This package supports visual mode's `s )` set of commands for a configurable\n set of pairs.\n\n* Next on the roadmap are pair deletions with `d )` and friends.\n\n* New in 0.4: Multiple cursors are now supported, and conveniently work just\n like you think they do.\n\n* New in 0.5: Stable configuration changes and configurable surround key!\n\n* New in 0.7: Change surround and delete surround added.\n\n### Muscle Memory Compatability Note\n\nvim-surround uses a lowercase `s` instead of `S` for surround commands! This is\nconfigurable in the package settings, if you would like to set it to the\noriginal keybinding.\n\n## How to use Surround\n\n### Surrounding\n\nFor double quotes, highlight the string in visual mode and enter `s \"`.\n\n```\nHello world -> \"Hello world\"\n```\n\nFor parentheses there are two options. `s )` will surround as normal. `s (`\nwill pad with a space. All asymmetrical pairs have the secondary space-padded\nform.\n\nFor example:\n\n`s )`\n\n```\nHello world -> (Hello world)\n```\n\n`s (`\n\n```\nHello world -> ( Hello world )\n```\n\n### Changing Surrounding Pairs\n\nSuppose I want to make double quotes into single quotes. To do this, I should\nput my cursor inside the double quotes in question and enter `c s \" '`\n\n```\n\"Hello world\" -> 'Hello world'\n```\n\n### Deleting Surrounding Pairs\n\nTo delete the single quotes, place your cursor inside of them and enter `d s '`\n\n```\n'Hello world' -> Hello world\n```\n### Configuration\n\nCurrently, the following pairs work out of the box!:\n\n- ()\n- []\n- {}\n- \"\"\n- ''\n\nYou can add to the available pairs in atom's settings, and the commands will\nbe dynamically added to your keybindings.\n\nFor example if I'm working on Jinja templates, and I want to add the ability to\nsurround using `{%` and `%}` I would add this in my settings:\n\n```\n(), [], {}, \"\", '', {%%}\n```\n\nThen:\n\n`s % }`\n\n```\nHello world -> {%Hello world%}\n```\n\n`s { %`\n\n```\nHello world -> {% Hello world %}\n```\n\n### TODO\n\n- [x] Implement deleting surrounding pairs with `d s`\n- [x] Implement changing surrounding pairs with `c s`\n- [ ] Intelligent tag surrounding/deleting/replacing with `s <q>` and friends.\n", + "readmeFilename": "README.md", + "bugs": { + "url": "https://github.com/gepoch/vim-surround/issues" + }, + "homepage": "https://github.com/gepoch/vim-surround", + "_id": "vim-surround@0.7.2", + "_shasum": "34c0ad724ca6be2fbe6f708455bddc5f5964eb19", + "_resolved": "file:../d-11562-86965-1746m6m/package.tgz", + "_from": "../d-11562-86965-1746m6m/package.tgz", + "_atomModuleCache": { + "version": 1, + "dependencies": [], + "extensions": { + ".coffee": [ + "lib/command/base.coffee", + "lib/command/change.coffee", + "lib/command/delete.coffee", + "lib/command/selector.coffee", + "lib/command/surround.coffee", + "lib/vim-surround.coffee" + ], + ".json": [ + "package.json" + ] + }, + "folders": [] + } +}
\ No newline at end of file diff --git a/atom/packages/vim-surround/spec/spec-helper.coffee b/atom/packages/vim-surround/spec/spec-helper.coffee new file mode 100644 index 0000000..931e0b9 --- /dev/null +++ b/atom/packages/vim-surround/spec/spec-helper.coffee @@ -0,0 +1,13 @@ +getEditorElement = (callback) -> + textEditor = null + + waitsForPromise -> + atom.project.open().then (e) -> + textEditor = e + + runs -> + element = document.createElement("atom-text-editor") + element.setModel(textEditor) + callback(element) + +module.exports = { getEditorElement } diff --git a/atom/packages/vim-surround/spec/vim-surround-spec.coffee b/atom/packages/vim-surround/spec/vim-surround-spec.coffee new file mode 100644 index 0000000..41a348e --- /dev/null +++ b/atom/packages/vim-surround/spec/vim-surround-spec.coffee @@ -0,0 +1,72 @@ +helpers = require './spec-helper' + +describe "Vim Surround activation", -> + [editor, pairs, editorElement, vimSurround, configPairs, chars, names] = [] + + beforeEach -> + pairs = ['()', '{}', '[]', '""', "''"] + atom.config.set('vim-surround.pairs', pairs) + + vimSurround = atom.packages.loadPackage('vim-surround') + vimSurround.activate() + + configPairs = atom.config.get('vim-surround.pairs') + + helpers.getEditorElement (element) -> + editorElement = element + editor = editorElement.getModel() + + editorClassList = editorElement.classList + + editorClassList.add('editor') + editorClassList.add('vim-mode') + editorClassList.add('visual-mode') + + + describe "When the vim-surround module loads", -> + beforeEach -> + chars = [] + pairs.forEach (pair) -> + for i in [0..pair.length-1] + char = pair[i] + chars.push char unless char in chars + + commands = atom.commands.findCommands target: editorElement + + names = [] + commands.forEach (command) -> + names.push(command.name) + + it "Creates a surround command for each configured pair character", -> + chars.forEach (char) -> + expect(names).toContain("vim-surround:surround-#{char}") + + describe "and the list of pairs changes", -> + beforeEach -> + pairs = ['()', '{}', '[]', '""', "-+"] + atom.config.set('vim-surround.pairs', pairs) + commands = atom.commands.findCommands target: editorElement + names = (command.name for command in commands) + chars = [] + pairs.forEach (pair) -> + for i in [0..pair.length-1] + char = pair[i] + chars.push char unless char in chars + + it "should add any new pairs.", -> + chars.forEach (char) -> + expect(names).toContain("vim-surround:surround-#{char}") + + it "should remove any old pairs.", -> + expect(names).not.toContain("vim-surround:surround-'") + + describe "and then deactivates", -> + + beforeEach -> + vimSurround.deactivate() + commands = atom.commands.findCommands target: editorElement + names = (command.name for command in commands) + + it "should clear out all commands from the registry", -> + chars.forEach (char) -> + expect(names).not.toContain("vim-surround:surround-#{char}") |