meta-x removes text from buffer and places it on the clipboard

This commit is contained in:
Corey Johnson
2012-02-02 09:35:18 -08:00
parent 3c37c0ebeb
commit d2a6eca8f3
4 changed files with 49 additions and 16 deletions

View File

@@ -512,20 +512,16 @@ describe "Editor", ->
expect(editor.clipPosition(row: 1, column: -5)).toEqual(row: 1, column: 0)
describe "cut, copy & paste", ->
describe "when a paste event is triggered", ->
beforeEach ->
atom.native.writeToPasteboard('first')
expect(atom.native.readFromPasteboard()).toBe 'first'
beforeEach ->
atom.native.writeToPasteboard('first')
expect(atom.native.readFromPasteboard()).toBe 'first'
it "pastes text into the buffer", ->
editor.setCursorPosition [0, 4]
editor.trigger "paste"
expect(editor.buffer.getLine(0)).toBe "var firstquicksort = function () {"
editor.getSelection().setRange new Range([1,6], [1,10])
editor.trigger "paste"
expect(editor.buffer.getLine(1)).toBe " var first = function(items) {"
expect(editor.buffer.getLine(1)).toBe " var sort = function(items) {"
describe "when a cut event is triggered", ->
it "removes the selected text from the buffer and places it on the pasteboard", ->
editor.getSelection().setRange new Range([0,4], [0,9])
editor.trigger "cut"
expect(editor.buffer.getLine(0)).toBe "var sort = function () {"
expect(atom.native.readFromPasteboard()).toBe 'quick'
describe "when a copy event is triggered", ->
it "copies selected text onto the clipboard", ->
@@ -533,3 +529,14 @@ describe "Editor", ->
editor.trigger "copy"
expect(atom.native.readFromPasteboard()).toBe 'quicksort'
describe "when a paste event is triggered", ->
it "pastes text into the buffer", ->
editor.setCursorPosition [0, 4]
editor.trigger "paste"
expect(editor.buffer.getLine(0)).toBe "var firstquicksort = function () {"
expect(editor.buffer.getLine(1)).toBe " var sort = function(items) {"
editor.getSelection().setRange new Range([1,6], [1,10])
editor.trigger "paste"
expect(editor.buffer.getLine(1)).toBe " var first = function(items) {"

View File

@@ -118,6 +118,28 @@ describe "Selection", ->
expect(selection.regions.length).toBe 3
expect(selection.find('.selection').length).toBe 3
describe ".cut()", ->
beforeEach ->
atom.native.writeToPasteboard('first')
expect(atom.native.readFromPasteboard()).toBe 'first'
it "removes selected text from the buffer and places it on the clipboard", ->
selection.setRange new Range([0,4], [0,13])
selection.cut()
expect(atom.native.readFromPasteboard()).toBe 'quicksort'
expect(editor.buffer.getLine(0)).toBe "var = function () {"
expect(selection.isEmpty()).toBeTruthy()
selection.setRange new Range([1,6], [3,8])
selection.cut()
expect(atom.native.readFromPasteboard()).toBe "sort = function(items) {\n if (items.length <= 1) return items;\n var "
expect(editor.buffer.getLine(1)).toBe " var pivot = items.shift(), current, left = [], right = [];"
it "places nothing on the clipboard when there is no selection", ->
selection.setRange new Range([0,4], [0,4])
selection.copy()
expect(atom.native.readFromPasteboard()).toBe 'first'
describe ".copy()", ->
beforeEach ->
atom.native.writeToPasteboard('first')
@@ -136,4 +158,3 @@ describe "Selection", ->
selection.setRange new Range([0,4], [0,4])
selection.copy()
expect(atom.native.readFromPasteboard()).toBe 'first'