mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04: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:
@@ -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) =>
|
||||
|
||||
Reference in New Issue
Block a user