mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 15:37:46 +03:00
Add columnCount
var to Editor::moveLeft and Cursor::moveLeft
This commit is contained in:
parent
851034c8d3
commit
99c07decf2
@ -333,12 +333,22 @@ describe "Editor", ->
|
||||
editor.moveLeft()
|
||||
expect(editor.getCursorScreenPosition()).toEqual(row: 0, column: buffer.lineForRow(0).length)
|
||||
|
||||
it "moves the cursor by n columns to the left", ->
|
||||
editor.setCursorScreenPosition([1, 0])
|
||||
editor.moveLeft(4)
|
||||
expect(editor.getCursorScreenPosition()).toEqual [0, 26]
|
||||
|
||||
describe "when the cursor is on the first line", ->
|
||||
it "remains in the same position (0,0)", ->
|
||||
editor.setCursorScreenPosition(row: 0, column: 0)
|
||||
editor.moveLeft()
|
||||
expect(editor.getCursorScreenPosition()).toEqual(row: 0, column: 0)
|
||||
|
||||
it "moves the cursor by n columns to the left", ->
|
||||
editor.setCursorScreenPosition([0, 0])
|
||||
editor.moveLeft(4)
|
||||
expect(editor.getCursorScreenPosition()).toEqual [0, 0]
|
||||
|
||||
describe "when softTabs is enabled and the cursor is preceded by leading whitespace", ->
|
||||
it "skips tabLength worth of whitespace at a time", ->
|
||||
editor.setCursorBufferPosition([5, 6])
|
||||
|
@ -270,7 +270,14 @@ class Cursor extends Model
|
||||
@setScreenPosition(range.start)
|
||||
else
|
||||
{row, column} = @getScreenPosition()
|
||||
[row, column] = if column > 0 then [row, column - 1] else [row - 1, Infinity]
|
||||
newColumn = column - columnCount
|
||||
|
||||
if newColumn >= 0
|
||||
column = newColumn
|
||||
else if row > 0
|
||||
row--
|
||||
column = @editor.lineTextForScreenRow(row).length + newColumn + 1
|
||||
|
||||
@setScreenPosition({row, column})
|
||||
|
||||
# Public: Moves the cursor right one screen column.
|
||||
|
@ -1636,8 +1636,8 @@ class Editor extends Model
|
||||
@moveDown(lineCount)
|
||||
|
||||
# Essential: Move every cursor left one column.
|
||||
moveLeft: ->
|
||||
@moveCursors (cursor) -> cursor.moveLeft(moveToEndOfSelection: true)
|
||||
moveLeft: (columnCount) ->
|
||||
@moveCursors (cursor) -> cursor.moveLeft(columnCount, moveToEndOfSelection: true)
|
||||
moveCursorLeft: ->
|
||||
deprecate("Use Editor::moveLeft() instead")
|
||||
@moveLeft()
|
||||
|
Loading…
Reference in New Issue
Block a user