mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 15:37:46 +03:00
parent
43acb99f86
commit
7a87c22c7d
@ -2484,6 +2484,22 @@ describe "TextEditor", ->
|
||||
|
||||
expect(clipboard.readText()).toBe 'quicksort\nsort'
|
||||
|
||||
describe "when no text is selected", ->
|
||||
beforeEach ->
|
||||
editor.setSelectedBufferRanges([[1, 0], [1, 0]])
|
||||
editor.addCursorAtBufferPosition([5, 0])
|
||||
|
||||
it "cuts the lines on which there are cursors", ->
|
||||
editor.cutSelectedText()
|
||||
|
||||
expect(buffer.getLineCount()).toBe(11)
|
||||
expect(buffer.lineForRow(1)).toBe(" if (items.length <= 1) return items;")
|
||||
expect(buffer.lineForRow(4)).toBe(" current < pivot ? left.push(current) : right.push(current);")
|
||||
expect(atom.clipboard.readWithMetadata().metadata.selections).toEqual([
|
||||
"var quicksort = function () {\n"
|
||||
" current = items.shift();\n"
|
||||
])
|
||||
|
||||
describe ".cutToEndOfLine()", ->
|
||||
describe "when soft wrap is on", ->
|
||||
it "cuts up to the end of the line", ->
|
||||
@ -2528,6 +2544,18 @@ describe "TextEditor", ->
|
||||
'items'
|
||||
])
|
||||
|
||||
describe "when no text is selected", ->
|
||||
beforeEach ->
|
||||
editor.setSelectedBufferRanges([[1, 0], [1, 0]])
|
||||
editor.addCursorAtBufferPosition([5, 0])
|
||||
|
||||
it "copies the lines on which there are cursors", ->
|
||||
editor.copySelectedText()
|
||||
expect(atom.clipboard.readWithMetadata().metadata.selections).toEqual([
|
||||
"var quicksort = function () {\n"
|
||||
" current = items.shift();\n"
|
||||
])
|
||||
|
||||
describe ".pasteText()", ->
|
||||
it "pastes text into the buffer", ->
|
||||
atom.clipboard.write('first')
|
||||
|
@ -2463,6 +2463,7 @@ class TextEditor extends Model
|
||||
copySelectedText: ->
|
||||
maintainClipboard = false
|
||||
for selection in @getSelections()
|
||||
selection.selectLine() if selection.isEmpty()
|
||||
selection.copy(maintainClipboard)
|
||||
maintainClipboard = true
|
||||
|
||||
@ -2470,6 +2471,7 @@ class TextEditor extends Model
|
||||
cutSelectedText: ->
|
||||
maintainClipboard = false
|
||||
@mutateSelectedText (selection) ->
|
||||
selection.selectLine() if selection.isEmpty()
|
||||
selection.cut(maintainClipboard)
|
||||
maintainClipboard = true
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user