mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-14 04:29:04 +03:00
Eliminate Editor.getCursor
This commit is contained in:
parent
8727caf97a
commit
5146abb7e1
@ -43,15 +43,15 @@ describe "CommandInterpreter", ->
|
||||
|
||||
describe ".", ->
|
||||
it 'maintains the current selection', ->
|
||||
editor.getSelection().setBufferRange([[1,1], [2,2]])
|
||||
editor.setSelectionBufferRange([[1,1], [2,2]])
|
||||
interpreter.eval(editor, '.')
|
||||
expect(editor.getSelection().getBufferRange()).toEqual [[1,1], [2,2]]
|
||||
|
||||
editor.getSelection().setBufferRange([[1,1], [2,2]])
|
||||
editor.setSelectionBufferRange([[1,1], [2,2]])
|
||||
interpreter.eval(editor, '.,')
|
||||
expect(editor.getSelection().getBufferRange()).toEqual [[1,1], [12,2]]
|
||||
|
||||
editor.getSelection().setBufferRange([[1,1], [2,2]])
|
||||
editor.setSelectionBufferRange([[1,1], [2,2]])
|
||||
interpreter.eval(editor, ',.')
|
||||
expect(editor.getSelection().getBufferRange()).toEqual [[0,0], [2,2]]
|
||||
|
||||
@ -131,18 +131,21 @@ describe "CommandInterpreter", ->
|
||||
|
||||
describe "substitution", ->
|
||||
it "does nothing if there are no matches", ->
|
||||
editor.getSelection().setBufferRange([[6, 0], [6, 44]])
|
||||
editor.setSelectionBufferRange([[6, 0], [6, 44]])
|
||||
interpreter.eval(editor, 's/not-in-text/foo/')
|
||||
expect(buffer.lineForRow(6)).toBe ' current < pivot ? left.push(current) : right.push(current);'
|
||||
|
||||
it "performs a single substitution within the current selection", ->
|
||||
editor.getSelection().setBufferRange([[6, 0], [6, 44]])
|
||||
interpreter.eval(editor, 's/current/foo/')
|
||||
expect(buffer.lineForRow(6)).toBe ' foo < pivot ? left.push(current) : right.push(current);'
|
||||
describe "when not global", ->
|
||||
describe "when there is a single selection", ->
|
||||
it "performs a single substitution within the current selection", ->
|
||||
editor.setSelectionBufferRange([[6, 0], [6, 44]])
|
||||
interpreter.eval(editor, 's/current/foo/')
|
||||
expect(buffer.lineForRow(6)).toBe ' foo < pivot ? left.push(current) : right.push(current);'
|
||||
|
||||
describe "when suffixed with a g", ->
|
||||
describe "when global", ->
|
||||
it "performs a multiple substitutions within the current selection", ->
|
||||
editor.getSelection().setBufferRange([[6, 0], [6, 44]])
|
||||
editor.setSelectionBufferRange([[6, 0], [6, 44]])
|
||||
interpreter.eval(editor, 's/current/foo/g')
|
||||
expect(buffer.lineForRow(6)).toBe ' foo < pivot ? left.push(foo) : right.push(current);'
|
||||
|
||||
|
@ -202,7 +202,7 @@ describe "Editor", ->
|
||||
editor.setCursorScreenPosition(row: 2, column: 2)
|
||||
|
||||
it "moves the cursor to the character at the given row and column", ->
|
||||
expect(editor.getCursor().position()).toEqual(top: 2 * editor.lineHeight, left: 2 * editor.charWidth)
|
||||
expect(editor.find('.cursor').position()).toEqual(top: 2 * editor.lineHeight, left: 2 * editor.charWidth)
|
||||
|
||||
describe "if soft-wrap is enabled", ->
|
||||
beforeEach ->
|
||||
@ -1345,7 +1345,7 @@ describe "Editor", ->
|
||||
|
||||
expect(editor.lineHeight).not.toBeNull()
|
||||
expect(editor.charWidth).not.toBeNull()
|
||||
expect(editor.getCursor().offset()).toEqual pagePixelPositionForPoint(editor, [2, 2])
|
||||
expect(editor.find('.cursor').offset()).toEqual pagePixelPositionForPoint(editor, [2, 2])
|
||||
|
||||
it "is focused", ->
|
||||
editor.attachToDom()
|
||||
|
@ -345,15 +345,14 @@ class Editor extends View
|
||||
@lineHeight = fragment.outerHeight()
|
||||
fragment.remove()
|
||||
|
||||
getCursor: (index) -> @compositeCursor.getCursor(index)
|
||||
moveCursorUp: -> @compositeCursor.moveUp()
|
||||
moveCursorDown: -> @compositeCursor.moveDown()
|
||||
moveCursorRight: -> @compositeCursor.moveRight()
|
||||
moveCursorLeft: -> @compositeCursor.moveLeft()
|
||||
setCursorScreenPosition: (position) -> @compositeCursor.setScreenPosition(position)
|
||||
getCursorScreenPosition: -> @getCursor().getScreenPosition()
|
||||
getCursorScreenPosition: -> @compositeCursor.getCursor().getScreenPosition()
|
||||
setCursorBufferPosition: (position) -> @compositeCursor.setBufferPosition(position)
|
||||
getCursorBufferPosition: -> @getCursor().getBufferPosition()
|
||||
getCursorBufferPosition: -> @compositeCursor.getCursor().getBufferPosition()
|
||||
|
||||
getSelection: (index) -> @compositeSelection.getSelection(index)
|
||||
getSelections: -> @compositeSelection.getSelections()
|
||||
|
Loading…
Reference in New Issue
Block a user