Delete at the end of a line above a fold deletes the folded lines (leaving a newline)

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-06-14 16:58:29 -06:00
parent daa688b1e1
commit 1dfbaf67d1
5 changed files with 39 additions and 2 deletions

View File

@@ -155,4 +155,7 @@ class Cursor
getCurrentLineBufferRange: ->
@editSession.bufferRangeForBufferRow(@getCurrentBufferRow())
isAtEndOfLine: ->
@getBufferPosition().isEqual(@getCurrentLineBufferRange().end)
_.extend Cursor.prototype, EventEmitter

View File

@@ -126,6 +126,9 @@ class DisplayBuffer
return unless folds = @activeFolds[bufferRow]
(folds.sort (a, b) -> b.endRow - a.endRow)[0]
largestFoldStartingAtScreenRow: (screenRow) ->
@largestFoldStartingAtBufferRow(@bufferRowForScreenRow(screenRow))
screenLineRangeForBufferRange: (bufferRange) ->
@expandScreenRangeToLineEnds(
@lineMap.screenRangeForBufferRange(

View File

@@ -194,7 +194,7 @@ class EditSession
@displayBuffer.destroyFoldsContainingBufferRow(bufferRow)
unfoldCurrentRow: ->
@displayBuffer.largestFoldStartingAtBufferRow(@getLastCursor().getCurrentBufferRow())?.destroy()
@largestFoldStartingAtBufferRow(@getLastCursor().getCurrentBufferRow())?.destroy()
destroyFold: (foldId) ->
fold = @displayBuffer.foldsById[foldId]
@@ -207,6 +207,9 @@ class EditSession
largestFoldStartingAtBufferRow: (bufferRow) ->
@displayBuffer.largestFoldStartingAtBufferRow(bufferRow)
largestFoldStartingAtScreenRow: (screenRow) ->
@displayBuffer.largestFoldStartingAtScreenRow(screenRow)
autoIndentTextAfterBufferPosition: (text, bufferPosition) ->
return { text } unless @autoIndent
@tokenizedBuffer.autoIndentTextAfterBufferPosition(text, bufferPosition)

View File

@@ -145,7 +145,11 @@ class Selection
@deleteSelectedText()
delete: ->
@selectRight() if @isEmpty()
if @isEmpty()
if @cursor.isAtEndOfLine() and fold = @editSession.largestFoldStartingAtScreenRow(@cursor.getCurrentScreenRow() + 1)
@selectToBufferPosition(fold.getBufferRange().end)
else
@selectRight()
@deleteSelectedText()
deleteToEndOfWord: ->