From 50cf5f3e95ef922011f4c94b8ed7f42e15ba0a20 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Tue, 30 Sep 2014 09:33:50 -0700 Subject: [PATCH 1/2] Subscribe to editor commands We need to unsubscribe when the editor is removed! Closes #3651 --- src/text-editor-component.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/text-editor-component.coffee b/src/text-editor-component.coffee index 270404ef4..8519ac21d 100644 --- a/src/text-editor-component.coffee +++ b/src/text-editor-component.coffee @@ -514,8 +514,8 @@ TextEditorComponent = React.createClass addCommandListeners: (listenersByCommandName) -> {parentView} = @props - addListener = (command, listener) -> - parentView.command command, (event) -> + addListener = (command, listener) => + @subscribe parentView.command command, (event) -> event.stopPropagation() listener(event) From a8d93f9cf49dfb827f8119c24069d6d231e52cb1 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Tue, 30 Sep 2014 09:45:55 -0700 Subject: [PATCH 2/2] Spec for unsubscribing from commands --- spec/text-editor-component-spec.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/text-editor-component-spec.coffee b/spec/text-editor-component-spec.coffee index 180efeeb5..b3f268b56 100644 --- a/spec/text-editor-component-spec.coffee +++ b/spec/text-editor-component-spec.coffee @@ -2264,6 +2264,10 @@ describe "TextEditorComponent", -> wrapperView.detach() wrapperView.attachToDom() + wrapperView.trigger('core:move-right') + + expect(editor.getCursorBufferPosition()).toEqual [0, 1] + buildMouseEvent = (type, properties...) -> properties = extend({bubbles: true, cancelable: true}, properties...) properties.detail ?= 1