aboutsummaryrefslogtreecommitdiff
path: root/atom/packages/vim-surround/lib/command/change.coffee
diff options
context:
space:
mode:
authorBen Beltran <ben@nsovocal.com>2019-03-14 23:19:58 +0100
committerBen Beltran <ben@nsovocal.com>2019-03-14 23:19:58 +0100
commitb009b50e81b6c1d0d691505b5f5c0418f559bfc0 (patch)
tree5fae800e76219eba28634cb236565f9b4bb7a2f7 /atom/packages/vim-surround/lib/command/change.coffee
parent4efcafab7f0aa454f9ebe767133654bc9f44e12c (diff)
Remove Atom config
Diffstat (limited to 'atom/packages/vim-surround/lib/command/change.coffee')
-rw-r--r--atom/packages/vim-surround/lib/command/change.coffee74
1 files changed, 0 insertions, 74 deletions
diff --git a/atom/packages/vim-surround/lib/command/change.coffee b/atom/packages/vim-surround/lib/command/change.coffee
deleted file mode 100644
index 7bdf623..0000000
--- a/atom/packages/vim-surround/lib/command/change.coffee
+++ /dev/null
@@ -1,74 +0,0 @@
-{CompositeDisposable} = require 'atom'
-
-Base = require './base'
-Selector = require './selector'
-
-module.exports = class Change
- constructor: (config) ->
- @command = config.changeSurroundCommand
- @context = "atom-text-editor.vim-mode.normal-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)