Feature/yanking (#138)
* Support yanking * Remove unneeded code from yank spec
This commit is contained in:
parent
0de4c800ea
commit
2a5fe2c382
2 changed files with 20 additions and 0 deletions
|
|
@ -354,6 +354,11 @@ class Ex
|
||||||
|
|
||||||
editor.buffer.setTextInRange(range, '')
|
editor.buffer.setTextInRange(range, '')
|
||||||
|
|
||||||
|
yank: ({ range }) ->
|
||||||
|
range = [[range[0], 0], [range[1] + 1, 0]]
|
||||||
|
txt = atom.workspace.getActiveTextEditor().getTextInBufferRange(range)
|
||||||
|
atom.clipboard.write(txt);
|
||||||
|
|
||||||
set: ({ range, args }) ->
|
set: ({ range, args }) ->
|
||||||
args = args.trim()
|
args = args.trim()
|
||||||
if args == ""
|
if args == ""
|
||||||
|
|
|
||||||
|
|
@ -590,6 +590,21 @@ describe "the commands", ->
|
||||||
submitNormalModeInputText(':%substitute/abc/ghi/ig')
|
submitNormalModeInputText(':%substitute/abc/ghi/ig')
|
||||||
expect(editor.getText()).toEqual('ghiaghi\ndefdDEF\nghiaghi')
|
expect(editor.getText()).toEqual('ghiaghi\ndefdDEF\nghiaghi')
|
||||||
|
|
||||||
|
describe ":yank", ->
|
||||||
|
beforeEach ->
|
||||||
|
editor.setText('abc\ndef\nghi\njkl')
|
||||||
|
editor.setCursorBufferPosition([2, 0])
|
||||||
|
|
||||||
|
it "yanks the current line", ->
|
||||||
|
keydown(':')
|
||||||
|
submitNormalModeInputText('yank')
|
||||||
|
expect(atom.clipboard.read()).toEqual('ghi\n')
|
||||||
|
|
||||||
|
it "yanks the lines in the given range", ->
|
||||||
|
keydown(':')
|
||||||
|
submitNormalModeInputText('1,2yank')
|
||||||
|
expect(atom.clipboard.read()).toEqual('abc\ndef\n')
|
||||||
|
|
||||||
describe "illegal delimiters", ->
|
describe "illegal delimiters", ->
|
||||||
test = (delim) ->
|
test = (delim) ->
|
||||||
keydown(':')
|
keydown(':')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue