Fix join lines so that only a single space will exist between two lines that are joined.

This commit is contained in:
Adam Boesch
2014-10-06 23:44:39 -05:00
committed by Kevin Sawicki
parent 305b9bc030
commit ffa528001c

View File

@@ -461,7 +461,8 @@ class Selection extends Model
end--
@editor.buffer.deleteRows(start, end)
# Public: Joins the current line with the one below it.
# Public: Joins the current line with the one below it. Lines will
# be separated by a single space.
#
# If there selection spans more than one line, all the lines are joined together.
joinLines: ->
@@ -479,16 +480,21 @@ class Selection extends Model
if nextRow <= @editor.buffer.getLastRow() and @editor.buffer.lineLengthForRow(nextRow) > 0
@insertText(' ')
@cursor.moveToEndOfLine()
@modifySelection =>
@cursor.moveRight()
@cursor.moveToFirstCharacterOfLine()
@deleteSelectedText()
@selectToPreviousWordBoundary()
@deleteSelectedText()
@modifySelection =>
@cursor.moveRight()
@cursor.moveToFirstCharacterOfLine()
@deleteSelectedText()
@insertText(' ')
if joinMarker?
newSelectedRange = joinMarker.getBufferRange()
@setBufferRange(newSelectedRange)
joinMarker.destroy()
@cursor.moveLeft()
# Public: Removes one level of indent from the currently selected rows.
outdentSelectedRows: ->
[start, end] = @getBufferRowRange()