1 {CompositeDisposable} = require 'atom'
3 Base = require './base'
4 Selector = require './selector'
6 module.exports = class Delete extends Base
7 constructor: (config) ->
8 @command = config.deleteSurroundCommand
9 @context = "atom-text-editor.vim-mode.command-mode"
12 getName: (key) -> "delete-#{key}"
14 getRunner: (left, right) -> ->
15 editor = atom.workspace.getActiveTextEditor()
16 selector = new Selector(editor, left, right)
19 cursorPos = editor.getCursorBufferPosition()
21 selector.inside().select()
22 editor.selections.forEach (selection) ->
23 text = selection.getText()
25 # restore cursore and select text with surrounding keys
26 editor.setCursorBufferPosition(cursorPos)
27 selector.outside().select()
29 editor.selections.forEach (selection) ->
30 selection.insertText text
33 editor.setCursorBufferPosition(cursorPos)