From 4b4dc7224eb101dd39cd09912789ed525b021155 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 15:54:28 -0700 Subject: [PATCH 01/30] Deprecate pane:removed event --- src/workspace-view.coffee | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index a46b46434..a4e5bc1b8 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -167,6 +167,17 @@ class WorkspaceView extends View @command 'core:save', => @saveActivePaneItem() @command 'core:save-as', => @saveActivePaneItemAs() + @setupViewEventDeprecations() + + setupViewEventDeprecations: -> + originalOn = @on + + @on = (eventName) => + switch eventName + when 'pane:removed' + deprecate("Use Pane::onDidDestroy instead") + originalOn.apply(this, arguments) + ### Section: Accessing the Workspace Model ### From c5f593cf083df9a4bdeaa599838795964b166355 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 15:55:41 -0700 Subject: [PATCH 02/30] deprecatedViewEvents -> setupViewEventDeprecations --- src/workspace-view.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index a4e5bc1b8..72fdfd9d9 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -167,9 +167,9 @@ class WorkspaceView extends View @command 'core:save', => @saveActivePaneItem() @command 'core:save-as', => @saveActivePaneItemAs() - @setupViewEventDeprecations() + @deprecatedViewEvents() - setupViewEventDeprecations: -> + deprecatedViewEvents: -> originalOn = @on @on = (eventName) => From ee701f3b8b0ae364164c8a59eb79da563d50ac66 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 15:57:16 -0700 Subject: [PATCH 03/30] Deprecate cursor:moved --- src/workspace-view.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 72fdfd9d9..d8ef8029c 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -175,7 +175,9 @@ class WorkspaceView extends View @on = (eventName) => switch eventName when 'pane:removed' - deprecate("Use Pane::onDidDestroy instead") + deprecate('Use Pane::onDidDestroy instead') + when 'cursor:moved' + deprecate('Use Editor::onDidChangeCursorPosition instead') originalOn.apply(this, arguments) ### From ce887fe877504273544ba77fbbfb09fcb37941b7 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 15:58:03 -0700 Subject: [PATCH 04/30] Deprecate selection:changed --- src/workspace-view.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index d8ef8029c..b37dd184f 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -178,6 +178,8 @@ class WorkspaceView extends View deprecate('Use Pane::onDidDestroy instead') when 'cursor:moved' deprecate('Use Editor::onDidChangeCursorPosition instead') + when 'selection:changed' + deprecate('Use Editor::onDidChangeSelectionRange instead') originalOn.apply(this, arguments) ### From 7344ba644e7ff0b758a4b4aedb38ec62facb8bbc Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 15:59:07 -0700 Subject: [PATCH 05/30] Deprecate pane-container:active-pane-item-changed --- src/workspace-view.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index b37dd184f..6484c0b05 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -176,6 +176,8 @@ class WorkspaceView extends View switch eventName when 'pane:removed' deprecate('Use Pane::onDidDestroy instead') + when 'pane-container:active-pane-item-changed' + deprecate('Use Workspace::onDidChangeActivePaneItem instead') when 'cursor:moved' deprecate('Use Editor::onDidChangeCursorPosition instead') when 'selection:changed' From 4521eeaeb1c7875734007b2ed899bdf7addc3ebf Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 16:01:17 -0700 Subject: [PATCH 06/30] Deprecate pane:active-item-changed --- src/workspace-view.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 6484c0b05..b226ada0e 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -174,6 +174,8 @@ class WorkspaceView extends View @on = (eventName) => switch eventName + when 'pane:active-item-changed' + deprecate('Use Pane::onDidChangeActiveItem instead') when 'pane:removed' deprecate('Use Pane::onDidDestroy instead') when 'pane-container:active-pane-item-changed' From fdddccf0944a75a5c57fed187a8d232d1401665c Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 16:01:41 -0700 Subject: [PATCH 07/30] :lipstick: --- src/workspace-view.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index b226ada0e..98e9051c7 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -174,14 +174,14 @@ class WorkspaceView extends View @on = (eventName) => switch eventName + when 'cursor:moved' + deprecate('Use Editor::onDidChangeCursorPosition instead') when 'pane:active-item-changed' deprecate('Use Pane::onDidChangeActiveItem instead') when 'pane:removed' deprecate('Use Pane::onDidDestroy instead') when 'pane-container:active-pane-item-changed' deprecate('Use Workspace::onDidChangeActivePaneItem instead') - when 'cursor:moved' - deprecate('Use Editor::onDidChangeCursorPosition instead') when 'selection:changed' deprecate('Use Editor::onDidChangeSelectionRange instead') originalOn.apply(this, arguments) From 5148deded15cb5f207ad42c58e12a0379a306db8 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 16:03:30 -0700 Subject: [PATCH 08/30] Deprecate pane:became-active --- src/workspace-view.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 98e9051c7..556d37fde 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -178,6 +178,8 @@ class WorkspaceView extends View deprecate('Use Editor::onDidChangeCursorPosition instead') when 'pane:active-item-changed' deprecate('Use Pane::onDidChangeActiveItem instead') + when 'pane:became-active' + deprecate('Use Pane::onDidActivate instead') when 'pane:removed' deprecate('Use Pane::onDidDestroy instead') when 'pane-container:active-pane-item-changed' From 33fdb0b518b646cbac4049593336c7c665986703 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 16:04:17 -0700 Subject: [PATCH 09/30] Deprecate pane:became-inactive --- src/workspace-view.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 556d37fde..979c79bff 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -180,6 +180,8 @@ class WorkspaceView extends View deprecate('Use Pane::onDidChangeActiveItem instead') when 'pane:became-active' deprecate('Use Pane::onDidActivate instead') + when 'pane:became-inactive' + depcreate('Use Pane::onDidChangeActive instead') when 'pane:removed' deprecate('Use Pane::onDidDestroy instead') when 'pane-container:active-pane-item-changed' From 099953c58b215578736a7340d78149fa034d8d90 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 16:05:49 -0700 Subject: [PATCH 10/30] Deprecate uri-opened --- src/workspace-view.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 979c79bff..574d21ea7 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -188,6 +188,8 @@ class WorkspaceView extends View deprecate('Use Workspace::onDidChangeActivePaneItem instead') when 'selection:changed' deprecate('Use Editor::onDidChangeSelectionRange instead') + when 'uri-opened' + deprecate('Use Workspace::onDidOpen instead') originalOn.apply(this, arguments) ### From c2c0962e3bd98bf49e89097027bb912e0937df14 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 16:07:44 -0700 Subject: [PATCH 11/30] Deprecate pane:item-added --- src/workspace-view.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 574d21ea7..04a426d1c 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -181,7 +181,9 @@ class WorkspaceView extends View when 'pane:became-active' deprecate('Use Pane::onDidActivate instead') when 'pane:became-inactive' - depcreate('Use Pane::onDidChangeActive instead') + deprecate('Use Pane::onDidChangeActive instead') + when 'pane:item-added' + deprecate('Use Pane::onDidAddItem instead') when 'pane:removed' deprecate('Use Pane::onDidDestroy instead') when 'pane-container:active-pane-item-changed' From 1850197f5509580c12854d88c6c9af9be5c97fac Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 16:20:31 -0700 Subject: [PATCH 12/30] Deprecate pane:item-removed --- src/workspace-view.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 04a426d1c..3a46e6410 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -184,6 +184,8 @@ class WorkspaceView extends View deprecate('Use Pane::onDidChangeActive instead') when 'pane:item-added' deprecate('Use Pane::onDidAddItem instead') + when 'pane:item-removed' + deprecate('Use Pane::onDidRemoveItem instead') when 'pane:removed' deprecate('Use Pane::onDidDestroy instead') when 'pane-container:active-pane-item-changed' From 291b989ff00c472b9e84b18c357aae5fe58435a6 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 16:21:19 -0700 Subject: [PATCH 13/30] Deprecate pane:item-moved --- src/workspace-view.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 3a46e6410..270deb17b 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -184,6 +184,8 @@ class WorkspaceView extends View deprecate('Use Pane::onDidChangeActive instead') when 'pane:item-added' deprecate('Use Pane::onDidAddItem instead') + when 'pane:item-moved' + deprecate('Use Pane::onDidMoveItem instead') when 'pane:item-removed' deprecate('Use Pane::onDidRemoveItem instead') when 'pane:removed' From 1b25ea8a8d1ca3e034ef77e0595d59b7990c7e8b Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 16:33:05 -0700 Subject: [PATCH 14/30] Deprecate custom events on EditorView --- src/workspace-view.coffee | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 270deb17b..1f858d8a8 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -198,6 +198,16 @@ class WorkspaceView extends View deprecate('Use Workspace::onDidOpen instead') originalOn.apply(this, arguments) + EditorView = require './editor-view' + originalEditorOn = EditorView::on + EditorView::on = (eventName) -> + switch eventName + when 'cursor:moved' + deprecate('Use Editor::onDidChangeCursorPosition instead') + when 'selection:changed' + deprecate('Use Editor::onDidChangeSelectionRange instead') + originalEditorOn.apply(this, arguments) + ### Section: Accessing the Workspace Model ### From cf303a73b7c397472fdb1bf699248c1a12955fdf Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 16:34:38 -0700 Subject: [PATCH 15/30] Deprecate custom events on PaneView --- src/workspace-view.coffee | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 1f858d8a8..dfb435dc4 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -170,7 +170,7 @@ class WorkspaceView extends View @deprecatedViewEvents() deprecatedViewEvents: -> - originalOn = @on + originalWorkspaceViewOn = @on @on = (eventName) => switch eventName @@ -196,17 +196,40 @@ class WorkspaceView extends View deprecate('Use Editor::onDidChangeSelectionRange instead') when 'uri-opened' deprecate('Use Workspace::onDidOpen instead') - originalOn.apply(this, arguments) + originalWorkspaceViewOn.apply(this, arguments) EditorView = require './editor-view' - originalEditorOn = EditorView::on + originalEditorViewOn = EditorView::on EditorView::on = (eventName) -> switch eventName when 'cursor:moved' deprecate('Use Editor::onDidChangeCursorPosition instead') when 'selection:changed' deprecate('Use Editor::onDidChangeSelectionRange instead') - originalEditorOn.apply(this, arguments) + originalEditorViewOn.apply(this, arguments) + + originalPaneViewOn = PaneView::on + PaneView::on = (eventName) -> + switch eventName + when 'cursor:moved' + deprecate('Use Editor::onDidChangeCursorPosition instead') + when 'pane:active-item-changed' + deprecate('Use Pane::onDidChangeActiveItem instead') + when 'pane:became-active' + deprecate('Use Pane::onDidActivate instead') + when 'pane:became-inactive' + deprecate('Use Pane::onDidChangeActive instead') + when 'pane:item-added' + deprecate('Use Pane::onDidAddItem instead') + when 'pane:item-moved' + deprecate('Use Pane::onDidMoveItem instead') + when 'pane:item-removed' + deprecate('Use Pane::onDidRemoveItem instead') + when 'pane:removed' + deprecate('Use Pane::onDidDestroy instead') + when 'selection:changed' + deprecate('Use Editor::onDidChangeSelectionRange instead') + originalPaneViewOn.apply(this, arguments) ### Section: Accessing the Workspace Model From b1994b28b357b9155daf50a8048d00bce0a85932 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 17:09:53 -0700 Subject: [PATCH 16/30] Deprecate pane:active-item-title-changed --- src/workspace-view.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index dfb435dc4..2d5bf70fa 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -178,6 +178,8 @@ class WorkspaceView extends View deprecate('Use Editor::onDidChangeCursorPosition instead') when 'pane:active-item-changed' deprecate('Use Pane::onDidChangeActiveItem instead') + when 'pane:active-item-title-changed' + deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeTitle on the active item instead') when 'pane:became-active' deprecate('Use Pane::onDidActivate instead') when 'pane:became-inactive' From 088d4f439f4af781201b6b6f4e81ec83aefd2bc2 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 17:12:30 -0700 Subject: [PATCH 17/30] Deprecate pane:active-item-title-changed on PaneView --- src/workspace-view.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 2d5bf70fa..609795bee 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -217,6 +217,8 @@ class WorkspaceView extends View deprecate('Use Editor::onDidChangeCursorPosition instead') when 'pane:active-item-changed' deprecate('Use Pane::onDidChangeActiveItem instead') + when 'pane:active-item-title-changed' + deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeTitle on the active item instead') when 'pane:became-active' deprecate('Use Pane::onDidActivate instead') when 'pane:became-inactive' From ddc88ec3ed9103a64649844172eca6f86d270311 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 17:14:32 -0700 Subject: [PATCH 18/30] Deprecate when pane:active-item-modified-status-changed --- src/workspace-view.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 609795bee..5b79bfe64 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -178,6 +178,8 @@ class WorkspaceView extends View deprecate('Use Editor::onDidChangeCursorPosition instead') when 'pane:active-item-changed' deprecate('Use Pane::onDidChangeActiveItem instead') + when 'pane:active-item-modified-status-changed' + deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeModified on the active item instead') when 'pane:active-item-title-changed' deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeTitle on the active item instead') when 'pane:became-active' @@ -217,6 +219,8 @@ class WorkspaceView extends View deprecate('Use Editor::onDidChangeCursorPosition instead') when 'pane:active-item-changed' deprecate('Use Pane::onDidChangeActiveItem instead') + when 'pane:active-item-modified-status-changed' + deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeModified on the active item instead') when 'pane:active-item-title-changed' deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeTitle on the active item instead') when 'pane:became-active' From a5b7764b38a8e8abe467fbc144d5697c5c90e44b Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 17:25:14 -0700 Subject: [PATCH 19/30] Deprecate pane:attached --- src/workspace-view.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 5b79bfe64..6dc129821 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -182,6 +182,8 @@ class WorkspaceView extends View deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeModified on the active item instead') when 'pane:active-item-title-changed' deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeTitle on the active item instead') + when 'pane:attached' + deprecate('Use Workspace::onDidAddPane instead') when 'pane:became-active' deprecate('Use Pane::onDidActivate instead') when 'pane:became-inactive' @@ -223,6 +225,8 @@ class WorkspaceView extends View deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeModified on the active item instead') when 'pane:active-item-title-changed' deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeTitle on the active item instead') + when 'pane:attached' + deprecate('Use Workspace::onDidAddPane instead') when 'pane:became-active' deprecate('Use Pane::onDidActivate instead') when 'pane:became-inactive' From 31dd10934360e5f0e6754a7b025358c0c6bd4db6 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 17:36:06 -0700 Subject: [PATCH 20/30] Add Editor::onDidDestroy --- spec/editor-spec.coffee | 7 +++++++ src/editor.coffee | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/spec/editor-spec.coffee b/spec/editor-spec.coffee index 27a0dc099..a2381b29d 100644 --- a/spec/editor-spec.coffee +++ b/spec/editor-spec.coffee @@ -3229,6 +3229,13 @@ describe "Editor", -> editor.destroy() expect(buffer.getMarkerCount()).toBe 0 + it "notifies ::onDidDestroy observers when the editor is destroyed", -> + destroyObserverCalled = false + editor.onDidDestroy -> destroyObserverCalled = true + + editor.destroy() + expect(destroyObserverCalled).toBe true + describe ".joinLines()", -> describe "when no text is selected", -> describe "when the line below isn't empty", -> diff --git a/src/editor.coffee b/src/editor.coffee index 3e0b5bd37..f63dfc0b5 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -171,6 +171,7 @@ class Editor extends Model @buffer.release() @displayBuffer.destroy() @languageMode.destroy() + @emitter.emit 'did-destroy' ### Section: Event Subscription @@ -304,6 +305,14 @@ class Editor extends Model onDidSave: (callback) -> @getBuffer().onDidSave(callback) + # Public: Invoke the given callback when the editor is destroyed. + # + # * `callback` {Function} to be called when the editor is destroyed. + # + # Returns a {Disposable} on which `.dispose()` can be called to unsubscribe. + onDidDestroy: (callback) -> + @emitter.on 'did-destroy', callback + # Extended: Calls your `callback` when a {Cursor} is added to the editor. # Immediately calls your callback for each existing cursor. # From 6d2719c7830386fc062a50afeac05398d3985801 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 17:36:38 -0700 Subject: [PATCH 21/30] Deprecate editor:will-be-removed --- src/workspace-view.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 6dc129821..03f85b130 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -176,6 +176,8 @@ class WorkspaceView extends View switch eventName when 'cursor:moved' deprecate('Use Editor::onDidChangeCursorPosition instead') + when 'editor:will-be-removed' + deprecate('Use Editor::onDidDestroy instead') when 'pane:active-item-changed' deprecate('Use Pane::onDidChangeActiveItem instead') when 'pane:active-item-modified-status-changed' @@ -210,6 +212,8 @@ class WorkspaceView extends View switch eventName when 'cursor:moved' deprecate('Use Editor::onDidChangeCursorPosition instead') + when 'editor:will-be-removed' + deprecate('Use Editor::onDidDestroy instead') when 'selection:changed' deprecate('Use Editor::onDidChangeSelectionRange instead') originalEditorViewOn.apply(this, arguments) @@ -219,6 +223,8 @@ class WorkspaceView extends View switch eventName when 'cursor:moved' deprecate('Use Editor::onDidChangeCursorPosition instead') + when 'editor:will-be-removed' + deprecate('Use Editor::onDidDestroy instead') when 'pane:active-item-changed' deprecate('Use Pane::onDidChangeActiveItem instead') when 'pane:active-item-modified-status-changed' From 0b82e83806370a1460c956d4f1df7e30a7cbff9e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 17:42:27 -0700 Subject: [PATCH 22/30] Move deprecatedViewEvents to deprecated section --- src/workspace-view.coffee | 160 +++++++++++++++++++------------------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 03f85b130..9e94b9d8d 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -169,86 +169,6 @@ class WorkspaceView extends View @deprecatedViewEvents() - deprecatedViewEvents: -> - originalWorkspaceViewOn = @on - - @on = (eventName) => - switch eventName - when 'cursor:moved' - deprecate('Use Editor::onDidChangeCursorPosition instead') - when 'editor:will-be-removed' - deprecate('Use Editor::onDidDestroy instead') - when 'pane:active-item-changed' - deprecate('Use Pane::onDidChangeActiveItem instead') - when 'pane:active-item-modified-status-changed' - deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeModified on the active item instead') - when 'pane:active-item-title-changed' - deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeTitle on the active item instead') - when 'pane:attached' - deprecate('Use Workspace::onDidAddPane instead') - when 'pane:became-active' - deprecate('Use Pane::onDidActivate instead') - when 'pane:became-inactive' - deprecate('Use Pane::onDidChangeActive instead') - when 'pane:item-added' - deprecate('Use Pane::onDidAddItem instead') - when 'pane:item-moved' - deprecate('Use Pane::onDidMoveItem instead') - when 'pane:item-removed' - deprecate('Use Pane::onDidRemoveItem instead') - when 'pane:removed' - deprecate('Use Pane::onDidDestroy instead') - when 'pane-container:active-pane-item-changed' - deprecate('Use Workspace::onDidChangeActivePaneItem instead') - when 'selection:changed' - deprecate('Use Editor::onDidChangeSelectionRange instead') - when 'uri-opened' - deprecate('Use Workspace::onDidOpen instead') - originalWorkspaceViewOn.apply(this, arguments) - - EditorView = require './editor-view' - originalEditorViewOn = EditorView::on - EditorView::on = (eventName) -> - switch eventName - when 'cursor:moved' - deprecate('Use Editor::onDidChangeCursorPosition instead') - when 'editor:will-be-removed' - deprecate('Use Editor::onDidDestroy instead') - when 'selection:changed' - deprecate('Use Editor::onDidChangeSelectionRange instead') - originalEditorViewOn.apply(this, arguments) - - originalPaneViewOn = PaneView::on - PaneView::on = (eventName) -> - switch eventName - when 'cursor:moved' - deprecate('Use Editor::onDidChangeCursorPosition instead') - when 'editor:will-be-removed' - deprecate('Use Editor::onDidDestroy instead') - when 'pane:active-item-changed' - deprecate('Use Pane::onDidChangeActiveItem instead') - when 'pane:active-item-modified-status-changed' - deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeModified on the active item instead') - when 'pane:active-item-title-changed' - deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeTitle on the active item instead') - when 'pane:attached' - deprecate('Use Workspace::onDidAddPane instead') - when 'pane:became-active' - deprecate('Use Pane::onDidActivate instead') - when 'pane:became-inactive' - deprecate('Use Pane::onDidChangeActive instead') - when 'pane:item-added' - deprecate('Use Pane::onDidAddItem instead') - when 'pane:item-moved' - deprecate('Use Pane::onDidMoveItem instead') - when 'pane:item-removed' - deprecate('Use Pane::onDidRemoveItem instead') - when 'pane:removed' - deprecate('Use Pane::onDidDestroy instead') - when 'selection:changed' - deprecate('Use Editor::onDidChangeSelectionRange instead') - originalPaneViewOn.apply(this, arguments) - ### Section: Accessing the Workspace Model ### @@ -493,6 +413,86 @@ class WorkspaceView extends View Section: Deprecated ### + deprecatedViewEvents: -> + originalWorkspaceViewOn = @on + + @on = (eventName) => + switch eventName + when 'cursor:moved' + deprecate('Use Editor::onDidChangeCursorPosition instead') + when 'editor:will-be-removed' + deprecate('Use Editor::onDidDestroy instead') + when 'pane:active-item-changed' + deprecate('Use Pane::onDidChangeActiveItem instead') + when 'pane:active-item-modified-status-changed' + deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeModified on the active item instead') + when 'pane:active-item-title-changed' + deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeTitle on the active item instead') + when 'pane:attached' + deprecate('Use Workspace::onDidAddPane instead') + when 'pane:became-active' + deprecate('Use Pane::onDidActivate instead') + when 'pane:became-inactive' + deprecate('Use Pane::onDidChangeActive instead') + when 'pane:item-added' + deprecate('Use Pane::onDidAddItem instead') + when 'pane:item-moved' + deprecate('Use Pane::onDidMoveItem instead') + when 'pane:item-removed' + deprecate('Use Pane::onDidRemoveItem instead') + when 'pane:removed' + deprecate('Use Pane::onDidDestroy instead') + when 'pane-container:active-pane-item-changed' + deprecate('Use Workspace::onDidChangeActivePaneItem instead') + when 'selection:changed' + deprecate('Use Editor::onDidChangeSelectionRange instead') + when 'uri-opened' + deprecate('Use Workspace::onDidOpen instead') + originalWorkspaceViewOn.apply(this, arguments) + + EditorView = require './editor-view' + originalEditorViewOn = EditorView::on + EditorView::on = (eventName) -> + switch eventName + when 'cursor:moved' + deprecate('Use Editor::onDidChangeCursorPosition instead') + when 'editor:will-be-removed' + deprecate('Use Editor::onDidDestroy instead') + when 'selection:changed' + deprecate('Use Editor::onDidChangeSelectionRange instead') + originalEditorViewOn.apply(this, arguments) + + originalPaneViewOn = PaneView::on + PaneView::on = (eventName) -> + switch eventName + when 'cursor:moved' + deprecate('Use Editor::onDidChangeCursorPosition instead') + when 'editor:will-be-removed' + deprecate('Use Editor::onDidDestroy instead') + when 'pane:active-item-changed' + deprecate('Use Pane::onDidChangeActiveItem instead') + when 'pane:active-item-modified-status-changed' + deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeModified on the active item instead') + when 'pane:active-item-title-changed' + deprecate('Use Pane::onDidChangeActiveItem and call onDidChangeTitle on the active item instead') + when 'pane:attached' + deprecate('Use Workspace::onDidAddPane instead') + when 'pane:became-active' + deprecate('Use Pane::onDidActivate instead') + when 'pane:became-inactive' + deprecate('Use Pane::onDidChangeActive instead') + when 'pane:item-added' + deprecate('Use Pane::onDidAddItem instead') + when 'pane:item-moved' + deprecate('Use Pane::onDidMoveItem instead') + when 'pane:item-removed' + deprecate('Use Pane::onDidRemoveItem instead') + when 'pane:removed' + deprecate('Use Pane::onDidDestroy instead') + when 'selection:changed' + deprecate('Use Editor::onDidChangeSelectionRange instead') + originalPaneViewOn.apply(this, arguments) + # Deprecated eachPane: (callback) -> deprecate("Use WorkspaceView::eachPaneView instead") From 280a3c30e60f800c4dec15d9f655254074f330eb Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 17:44:21 -0700 Subject: [PATCH 23/30] Deprecate editor:attached --- src/workspace-view.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 9e94b9d8d..6a61fe1b2 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -420,6 +420,8 @@ class WorkspaceView extends View switch eventName when 'cursor:moved' deprecate('Use Editor::onDidChangeCursorPosition instead') + when 'editor:attached' + deprecate('Use Editor::onDidAddTextEditor instead') when 'editor:will-be-removed' deprecate('Use Editor::onDidDestroy instead') when 'pane:active-item-changed' @@ -456,6 +458,8 @@ class WorkspaceView extends View switch eventName when 'cursor:moved' deprecate('Use Editor::onDidChangeCursorPosition instead') + when 'editor:attached' + deprecate('Use Editor::onDidAddTextEditor instead') when 'editor:will-be-removed' deprecate('Use Editor::onDidDestroy instead') when 'selection:changed' @@ -467,6 +471,8 @@ class WorkspaceView extends View switch eventName when 'cursor:moved' deprecate('Use Editor::onDidChangeCursorPosition instead') + when 'editor:attached' + deprecate('Use Editor::onDidAddTextEditor instead') when 'editor:will-be-removed' deprecate('Use Editor::onDidDestroy instead') when 'pane:active-item-changed' From fe30cf2135ec10265d628dca94dfddc8319a50d1 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Sep 2014 17:47:08 -0700 Subject: [PATCH 24/30] Deprecate editor:detached --- src/workspace-view.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 6a61fe1b2..2496d47f0 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -422,6 +422,8 @@ class WorkspaceView extends View deprecate('Use Editor::onDidChangeCursorPosition instead') when 'editor:attached' deprecate('Use Editor::onDidAddTextEditor instead') + when 'editor:detached' + deprecate('Use Editor::onDidDestroy instead') when 'editor:will-be-removed' deprecate('Use Editor::onDidDestroy instead') when 'pane:active-item-changed' @@ -460,6 +462,8 @@ class WorkspaceView extends View deprecate('Use Editor::onDidChangeCursorPosition instead') when 'editor:attached' deprecate('Use Editor::onDidAddTextEditor instead') + when 'editor:detached' + deprecate('Use Editor::onDidDestroy instead') when 'editor:will-be-removed' deprecate('Use Editor::onDidDestroy instead') when 'selection:changed' @@ -473,6 +477,8 @@ class WorkspaceView extends View deprecate('Use Editor::onDidChangeCursorPosition instead') when 'editor:attached' deprecate('Use Editor::onDidAddTextEditor instead') + when 'editor:detached' + deprecate('Use Editor::onDidDestroy instead') when 'editor:will-be-removed' deprecate('Use Editor::onDidDestroy instead') when 'pane:active-item-changed' From 67610829f4405840e30864a1e587b38108ad64c7 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 18 Sep 2014 09:42:08 -0700 Subject: [PATCH 25/30] Add Atom::onDidBeep --- src/atom.coffee | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/atom.coffee b/src/atom.coffee index 3a84070f9..04361bf36 100644 --- a/src/atom.coffee +++ b/src/atom.coffee @@ -8,6 +8,7 @@ shell = require 'shell' _ = require 'underscore-plus' {deprecate} = require 'grim' +{Emitter} = require 'event-kit' {Model} = require 'theorist' fs = require 'fs-plus' @@ -147,6 +148,7 @@ class Atom extends Model # Call .loadOrCreate instead constructor: (@state) -> + @emitter = new Emitter {@mode} = @state DeserializerManager = require './deserializer-manager' @deserializers = new DeserializerManager() @@ -211,6 +213,18 @@ class Atom extends Model @windowEventHandler = new WindowEventHandler + ### + Section: Event Subscription + ### + + # Extended: Invoke the given callback whenever {::beep} is called. + # + # * `callback` {Function} to be called whenever {::beep} is called. + # + # Returns a {Disposable} on which `.dispose()` can be called to unsubscribe. + onDidBeep: (callback) -> + @emitter.on 'did-beep', callback + ### Section: Atom Metadata ### @@ -493,6 +507,7 @@ class Atom extends Model beep: -> shell.beep() if @config.get('core.audioBeep') @workspaceView.trigger 'beep' + @emitter.emit 'did-beep' # Essential: A flexible way to open a dialog akin to an alert dialog. # From 522a66c87693dc38bb3e18f047cc2221254bc1bc Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 18 Sep 2014 09:42:47 -0700 Subject: [PATCH 26/30] :memo: Wrap ::onDidAddPaneItem in {} --- src/workspace.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/workspace.coffee b/src/workspace.coffee index 31b7cb261..db97e6732 100644 --- a/src/workspace.coffee +++ b/src/workspace.coffee @@ -104,7 +104,7 @@ class Workspace extends Model @onDidAddTextEditor ({textEditor}) -> callback(textEditor) # Essential: Invoke the given callback whenever an item is opened. Unlike - # ::onDidAddPaneItem, observers will be notified for items that are already + # {::onDidAddPaneItem}, observers will be notified for items that are already # present in the workspace when they are reopened. # # * `callback` {Function} to be called whenever an item is opened. From 1a24c79c7f4825f46389feb77472d80094c9d1a6 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 18 Sep 2014 09:43:32 -0700 Subject: [PATCH 27/30] Deprecate beep event --- src/workspace-view.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/workspace-view.coffee b/src/workspace-view.coffee index 2496d47f0..547d8daa9 100644 --- a/src/workspace-view.coffee +++ b/src/workspace-view.coffee @@ -418,6 +418,8 @@ class WorkspaceView extends View @on = (eventName) => switch eventName + when 'beep' + deprecate('Use Atom::onDidBeep instead') when 'cursor:moved' deprecate('Use Editor::onDidChangeCursorPosition instead') when 'editor:attached' From 95253758f32f9e9f07a12c46e11dc1c65cac4f57 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 18 Sep 2014 10:09:28 -0700 Subject: [PATCH 28/30] Dispose emitter after emitting did-destroy --- src/editor.coffee | 1 + src/pane.coffee | 1 + 2 files changed, 2 insertions(+) diff --git a/src/editor.coffee b/src/editor.coffee index f63dfc0b5..c4b9716e4 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -172,6 +172,7 @@ class Editor extends Model @displayBuffer.destroy() @languageMode.destroy() @emitter.emit 'did-destroy' + @emitter.dispose() ### Section: Event Subscription diff --git a/src/pane.coffee b/src/pane.coffee index c6351f656..658cee6dd 100644 --- a/src/pane.coffee +++ b/src/pane.coffee @@ -518,6 +518,7 @@ class Pane extends Model destroyed: -> @container.activateNextPane() if @isActive() @emitter.emit 'did-destroy' + @emitter.dispose() item.destroy?() for item in @items.slice() ### From c291c705ec6acd2a2074f623c77627ce8c759344 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 18 Sep 2014 10:20:56 -0700 Subject: [PATCH 29/30] Add missing support to deprecation message --- src/pane-view.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pane-view.coffee b/src/pane-view.coffee index 21f4c8cfa..ddeab69af 100644 --- a/src/pane-view.coffee +++ b/src/pane-view.coffee @@ -162,7 +162,7 @@ class PaneView extends View deprecate 'Please return a Disposable object from your ::onDidChangeTitle method!' unless disposable?.dispose? @activeItemDisposables.add(disposable) if disposable?.dispose? else if item.on? - deprecate '::on methods for items are no longer supported. If you would like your item to title change behavior, please implement a ::onDidChangeTitle() method.' + deprecate '::on methods for items are no longer supported. If you would like your item to support title change behavior, please implement a ::onDidChangeTitle() method.' disposable = item.on('title-changed', @activeItemTitleChanged) @activeItemDisposables.add(disposable) if disposable?.dispose? From 62a5c1c58d654fa989f2e4f272b0686bdaa92d4c Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 18 Sep 2014 11:48:44 -0700 Subject: [PATCH 30/30] Don't dispose emitter, specs fail --- src/editor.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/src/editor.coffee b/src/editor.coffee index c4b9716e4..f63dfc0b5 100644 --- a/src/editor.coffee +++ b/src/editor.coffee @@ -172,7 +172,6 @@ class Editor extends Model @displayBuffer.destroy() @languageMode.destroy() @emitter.emit 'did-destroy' - @emitter.dispose() ### Section: Event Subscription