mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Merge cursors after buffer changes that didn't occur via the EditSession
The buffer now emits a new event 'update-anchors-after-change' to signal that all the anchors have been updated, which is an appropriate time to merge cursors.
This commit is contained in:
@@ -1362,14 +1362,12 @@ describe "EditSession", ->
|
||||
[cursor1, cursor2, cursor3] = editSession.getCursors()
|
||||
expect(editSession.getCursors().length).toBe 3
|
||||
|
||||
editSession.backspace()
|
||||
buffer.delete([[0, 0], [0, 1]])
|
||||
|
||||
expect(editSession.getCursors().length).toBe 2
|
||||
expect(editSession.getCursors()).toEqual [cursor1, cursor3]
|
||||
expect(cursor1.getBufferPosition()).toEqual [0,0]
|
||||
expect(cursor3.getBufferPosition()).toEqual [1,0]
|
||||
|
||||
editSession.insertText "x"
|
||||
expect(editSession.lineForBufferRow(0)).toBe "xar quicksort = function () {"
|
||||
expect(editSession.lineForBufferRow(1)).toBe "x var sort = function(items) {"
|
||||
expect(cursor3.getBufferPosition()).toEqual [1,1]
|
||||
|
||||
describe "folding", ->
|
||||
describe "structural folding", ->
|
||||
|
||||
@@ -42,6 +42,7 @@ class BufferChangeOperation
|
||||
event = { oldRange, newRange, oldText, newText }
|
||||
@buffer.trigger 'change', event
|
||||
anchor.handleBufferChange(event) for anchor in @buffer.getAnchors()
|
||||
@buffer.trigger 'update-anchors-after-change'
|
||||
newRange
|
||||
|
||||
calculateNewRange: (oldRange, newText) ->
|
||||
|
||||
@@ -45,7 +45,8 @@ class EditSession
|
||||
@buffer.on "path-change.edit-session-#{@id}", =>
|
||||
@trigger 'buffer-path-change'
|
||||
|
||||
@buffer.on "change.edit-session-#{@id}", (e) => @mergeCursors()
|
||||
@buffer.on "update-anchors-after-change.edit-session-#{@id}", =>
|
||||
@mergeCursors()
|
||||
|
||||
@displayBuffer.on "change.edit-session-#{@id}", (e) =>
|
||||
@trigger 'screen-lines-change', e
|
||||
|
||||
Reference in New Issue
Block a user