]> git.r.bdr.sh - rbdr/dotfiles/blame - atom/packages/vim-surround/lib/command/delete.coffee
Remove vim-surround
[rbdr/dotfiles] / atom / packages / vim-surround / lib / command / delete.coffee
CommitLineData
455f099b 1{compositedisposable} = require 'atom'
24c7594d
BB
2
3Base = require './base'
4Selector = require './selector'
5
6module.exports = class Delete extends Base
7 constructor: (config) ->
8 @command = config.deleteSurroundCommand
455f099b 9 @context = "atom-text-editor.vim-mode.normal-mode"
24c7594d
BB
10 super config
11
12 getName: (key) -> "delete-#{key}"
13
14 getRunner: (left, right) -> ->
15 editor = atom.workspace.getActiveTextEditor()
16 selector = new Selector(editor, left, right)
17
18 editor.transact ->
19 cursorPos = editor.getCursorBufferPosition()
20
21 selector.inside().select()
22 editor.selections.forEach (selection) ->
23 text = selection.getText()
24
25 # restore cursore and select text with surrounding keys
26 editor.setCursorBufferPosition(cursorPos)
27 selector.outside().select()
28
29 editor.selections.forEach (selection) ->
30 selection.insertText text
31
32 # restore cursore
33 editor.setCursorBufferPosition(cursorPos)