Backspace in column 0 below a fold absorbs line into fold

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-06-12 16:48:08 -07:00
parent feb0c6af85
commit 222e12d29d
4 changed files with 25 additions and 2 deletions

View File

@@ -764,6 +764,17 @@ describe "EditSession", ->
editSession.setCursorScreenPosition(row: 0, column: 0)
editSession.backspace()
describe "when the cursor is on the first column of a line below a fold", ->
it "absorbs the current line into the fold", ->
editSession.setCursorScreenPosition([4,0])
editSession.toggleFold()
editSession.setCursorScreenPosition([5,0])
editSession.backspace()
expect(buffer.lineForRow(7)).toBe " } return sort(left).concat(pivot).concat(sort(right));"
expect(buffer.lineForRow(8)).toBe " };"
describe "when there are multiple cursors", ->
describe "when cursors are on the same line", ->
it "removes the characters preceding each cursor", ->

View File

@@ -198,6 +198,9 @@ class EditSession
destroyFoldsContainingBufferRow: (bufferRow) ->
@renderer.destroyFoldsContainingBufferRow(bufferRow)
isFoldedAtScreenRow: (screenRow) ->
@screenLineForRow(screenRow).fold?
toggleLineCommentsInRange: (range) ->
@renderer.toggleLineCommentsInRange(range)

View File

@@ -341,7 +341,7 @@ class Editor extends View
@screenLineCount() - 1
isFoldedAtScreenRow: (screenRow) ->
@screenLineForRow(screenRow).fold?
@activeEditSession.isFoldedAtScreenRow(screenRow)
destroyFoldsContainingBufferRow: (bufferRow) ->
@renderer.destroyFoldsContainingBufferRow(bufferRow)

View File

@@ -86,6 +86,9 @@ class Selection
selectToScreenPosition: (position) ->
@modifySelection => @cursor.setScreenPosition(position)
selectToBufferPosition: (position) ->
@modifySelection => @cursor.setBufferPosition(position)
selectRight: ->
@modifySelection => @cursor.moveRight()
@@ -131,7 +134,13 @@ class Selection
backspace: ->
@editSession.destroyFoldsContainingBufferRow(@getBufferRange().end.row)
@selectLeft() if @isEmpty()
if @isEmpty()
if @editSession.isFoldedAtScreenRow(@cursor.getCurrentScreenRow() - 1)
@selectToBufferPosition([@cursor.getCurrentBufferRow() - 1, Infinity])
else
@selectLeft()
@deleteSelectedText()
backspaceToBeginningOfWord: ->