]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/vim-surround/lib/command/delete.coffee
Commit powerline changes, add git signing config
[rbdr/dotfiles] / atom / packages / vim-surround / lib / command / delete.coffee
1 {compositedisposable} = require 'atom'
2
3 Base = require './base'
4 Selector = require './selector'
5
6 module.exports = class Delete extends Base
7 constructor: (config) ->
8 @command = config.deleteSurroundCommand
9 @context = "atom-text-editor.vim-mode.normal-mode"
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)