@@ -78,7 +78,7 @@ export default class CodeFormatManager {
78
78
79
79
// Events from editor actions (saving, typing).
80
80
const editorEvents = observableFromSubscribeFunction ( ( cb ) => atom . workspace . observeTextEditors ( cb ) ) . mergeMap (
81
- ( editor ) => this . _getEditorEventStream ( editor )
81
+ ( editor ) => _getEditorEventStream ( editor )
82
82
)
83
83
84
84
return (
@@ -97,22 +97,6 @@ export default class CodeFormatManager {
97
97
)
98
98
}
99
99
100
- /** Returns a stream of all typing and saving operations from the editor. */
101
- _getEditorEventStream ( editor : TextEditor ) : Observable < FormatEvent > {
102
- const changeEvents = observableFromSubscribeFunction ( ( callback ) => editor . getBuffer ( ) . onDidChangeText ( callback ) )
103
-
104
- // We need to capture when editors are about to be destroyed in order to
105
- // interrupt any pending formatting operations. (Otherwise, we may end up
106
- // attempting to save a destroyed editor!)
107
- const willDestroyEvents = observableFromSubscribeFunction ( ( cb ) => atom . workspace . onWillDestroyPaneItem ( cb ) ) . filter (
108
- ( event ) => event . item === editor
109
- )
110
-
111
- return Observable . merge ( changeEvents . map ( ( edit ) => ( { type : "type" , editor, edit } ) ) ) . takeUntil (
112
- Observable . merge ( observeEditorDestroy ( editor ) , willDestroyEvents )
113
- )
114
- }
115
-
116
100
_handleEvent ( event : FormatEvent ) : Observable < unknown > {
117
101
const { editor } = event
118
102
switch ( event . type ) {
@@ -396,3 +380,19 @@ function _checkContentsAreSame(before: string, after: string): void {
396
380
throw new Error ( "The file contents were changed before formatting was complete." )
397
381
}
398
382
}
383
+
384
+ /** Returns a stream of all typing and saving operations from the editor. */
385
+ function _getEditorEventStream ( editor : TextEditor ) : Observable < FormatEvent > {
386
+ const changeEvents = observableFromSubscribeFunction ( ( callback ) => editor . getBuffer ( ) . onDidChangeText ( callback ) )
387
+
388
+ // We need to capture when editors are about to be destroyed in order to
389
+ // interrupt any pending formatting operations. (Otherwise, we may end up
390
+ // attempting to save a destroyed editor!)
391
+ const willDestroyEvents = observableFromSubscribeFunction ( ( cb ) => atom . workspace . onWillDestroyPaneItem ( cb ) ) . filter (
392
+ ( event ) => event . item === editor
393
+ )
394
+
395
+ return Observable . merge ( changeEvents . map ( ( edit ) => ( { type : "type" , editor, edit } ) ) ) . takeUntil (
396
+ Observable . merge ( observeEditorDestroy ( editor ) , willDestroyEvents )
397
+ )
398
+ }
0 commit comments