Display selections from all replicas

This commit is contained in:
Kevin Sawicki & Nathan Sobo
2013-07-23 16:41:38 -07:00
committed by Corey Johnson & Matt Colyer
parent b8b9653fc0
commit 1bf6307480
3 changed files with 38 additions and 1 deletions

View 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

View File

@@ -964,6 +964,9 @@ class EditSession
else
false
getAllSelections: ->
@getSelections().concat(@getRemoteSelections())
# Gets all the selections.
#
# Returns an {Array} of {Selection}s.

View File

@@ -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: ->