From de21db0ea8d4975e8a26dea5ca2f327adc2ac1aa Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 2 Jan 2013 03:22:08 -0700 Subject: [PATCH] Simplify `Editor` subscriptions We no longer subscribe to `RootView` so we don't need to unsubscribe. We can use `@subscribe` to subscribe to window, so we don't need to genette a unique id for the editor in order to unsubscribe, because the editor will unsubscribe automatically when removed now. --- src/app/editor.coffee | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 0fea3e92e..360f55a46 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -13,8 +13,6 @@ _ = require 'underscore' module.exports = class Editor extends View - @idCounter: 1 - @configDefaults: fontSize: 20 showInvisibles: false @@ -63,7 +61,6 @@ class Editor extends View initialize: ({editSession, @mini} = {}) -> requireStylesheet 'editor.css' - @id = Editor.idCounter++ @lineCache = [] @configure() @bindKeys() @@ -420,7 +417,7 @@ class Editor extends View @calculateDimensions() @hiddenInput.width(@charWidth) @setSoftWrapColumn() if @activeEditSession.getSoftWrap() - $(window).on "resize.editor#{@id}", => @requestDisplayUpdate() + @subscribe $(window), "resize", => @requestDisplayUpdate() @focus() if @isFocused @resetDisplay() @@ -616,7 +613,7 @@ class Editor extends View if @activeEditSession.getSoftWrap() @addClass 'soft-wrap' @_setSoftWrapColumn = => @setSoftWrapColumn() - $(window).on "resize.editor#{@id}", @_setSoftWrapColumn + $(window).on "resize", @_setSoftWrapColumn else @removeClass 'soft-wrap' $(window).off 'resize', @_setSoftWrapColumn @@ -687,9 +684,6 @@ class Editor extends View @destroyEditSessions() - $(window).off ".editor#{@id}" - rootView = @rootView() - rootView?.off ".editor#{@id}" if @pane() then @pane().remove() else super rootView?.focus()