mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Add Editor.spliceLineELements
This commit is contained in:
@@ -205,6 +205,24 @@ class Editor extends View
|
||||
else
|
||||
@updateLineElement(row, screenLines.shift())
|
||||
|
||||
|
||||
spliceLineElements: (startRow, rowCount, lineElements) ->
|
||||
endRow = startRow + rowCount
|
||||
insertBeforeElement = @lineCache[startRow]
|
||||
removeElements = $(_.map @lineCache[startRow...endRow], (elt) -> elt[0])
|
||||
@lineCache[startRow...endRow] = lineElements or []
|
||||
|
||||
if lineElements
|
||||
if removeElements.length
|
||||
removeElements.replaceWith(lineElements)
|
||||
else if insertBeforeElement
|
||||
insertBeforeElement.before(lineElements)
|
||||
else
|
||||
@lines.append(lineElements)
|
||||
else
|
||||
removeElements.remove()
|
||||
|
||||
|
||||
updateLineElement: (row, screenLine) ->
|
||||
if @lineCache.length == 0
|
||||
@insertLineElement(row, screenLine)
|
||||
|
||||
Reference in New Issue
Block a user