mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
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.
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user