mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Display selections from all replicas
This commit is contained in:
committed by
Corey Johnson & Matt Colyer
parent
b8b9653fc0
commit
1bf6307480
34
spec/app/editor-replication-spec.coffee
Normal file
34
spec/app/editor-replication-spec.coffee
Normal file
@@ -0,0 +1,34 @@
|
||||
{Site} = require 'telepath'
|
||||
Editor = require 'editor'
|
||||
Environment = require 'environment'
|
||||
|
||||
describe "Editor replication", ->
|
||||
[env1, env2, editSession1, editSession2, editor1, editor2] = []
|
||||
|
||||
beforeEach ->
|
||||
env1 = new Environment(siteId: 1)
|
||||
env2 = env1.clone(siteId: 2)
|
||||
envConnection = env1.connect(env2)
|
||||
doc2 = null
|
||||
|
||||
env1.run ->
|
||||
editSession1 = project.open('sample.js')
|
||||
editSession1.setSelectedBufferRange([[1, 2], [3, 4]])
|
||||
doc1 = editSession1.getState()
|
||||
doc2 = doc1.clone(env2.site)
|
||||
envConnection.connect(doc1, doc2)
|
||||
editor1 = new Editor(editSession1)
|
||||
editor1.attachToDom()
|
||||
|
||||
env2.run ->
|
||||
editSession2 = deserialize(doc2)
|
||||
editor2 = new Editor(editSession2)
|
||||
editor2.attachToDom()
|
||||
|
||||
afterEach ->
|
||||
env1.destroy()
|
||||
env2.destroy()
|
||||
|
||||
it "displays the selections from all replicas", ->
|
||||
expect(editor1.getSelectionViews().length).toBe 2
|
||||
expect(editor2.getSelectionViews().length).toBe 2
|
||||
@@ -964,6 +964,9 @@ class EditSession
|
||||
else
|
||||
false
|
||||
|
||||
getAllSelections: ->
|
||||
@getSelections().concat(@getRemoteSelections())
|
||||
|
||||
# Gets all the selections.
|
||||
#
|
||||
# Returns an {Array} of {Selection}s.
|
||||
|
||||
@@ -1102,7 +1102,7 @@ class Editor extends View
|
||||
@scrollTop(editSessionScrollTop)
|
||||
@scrollLeft(editSessionScrollLeft)
|
||||
@newCursors = @activeEditSession.getCursors()
|
||||
@newSelections = @activeEditSession.getSelections()
|
||||
@newSelections = @activeEditSession.getAllSelections()
|
||||
@updateDisplay(suppressAutoScroll: true)
|
||||
|
||||
requestDisplayUpdate: ->
|
||||
|
||||
Reference in New Issue
Block a user