mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 23:48:05 +03:00
Fix CommandRegistry::get/restoreSnapshot
I didn’t realize that deepClone was not handling functions correctly. I’ve implemented clone manually to the exact depth needed instead.
This commit is contained in:
parent
d506ccbaad
commit
6d55bab4c8
@ -152,12 +152,17 @@ class CommandRegistry
|
||||
@handleCommandEvent(eventWithTarget)
|
||||
|
||||
getSnapshot: ->
|
||||
_.deepClone(@listenersByCommandName)
|
||||
snapshot = {}
|
||||
for commandName, listeners of @listenersByCommandName
|
||||
snapshot[commandName] = listeners.slice()
|
||||
snapshot
|
||||
|
||||
restoreSnapshot: (snapshot) ->
|
||||
rootNode = @getRootNode()
|
||||
@setRootNode(null) # clear listeners for current commands
|
||||
@listenersByCommandName = _.deepClone(snapshot)
|
||||
@listenersByCommandName = {}
|
||||
for commandName, listeners of snapshot
|
||||
@listenersByCommandName[commandName] = listeners.slice()
|
||||
@setRootNode(rootNode) # restore listeners for commands in snapshot
|
||||
|
||||
handleCommandEvent: (originalEvent) =>
|
||||
|
Loading…
Reference in New Issue
Block a user