@@ -9,14 +9,7 @@ import * as path from 'path';
99import * as uuid from 'uuid/v4' ;
1010import { Event , EventEmitter , Memento , Uri , ViewColumn } from 'vscode' ;
1111
12- import {
13- IApplicationShell ,
14- ICommandManager ,
15- IDocumentManager ,
16- ILiveShareApi ,
17- IWebPanelProvider ,
18- IWorkspaceService
19- } from '../../common/application/types' ;
12+ import { IApplicationShell , ICommandManager , IDocumentManager , ILiveShareApi , IWebPanelProvider , IWorkspaceService } from '../../common/application/types' ;
2013import { ContextKey } from '../../common/contextKey' ;
2114import { traceError } from '../../common/logger' ;
2215import { IFileSystem , TemporaryFile } from '../../common/platform/types' ;
@@ -28,21 +21,9 @@ import { EXTENSION_ROOT_DIR } from '../../constants';
2821import { IInterpreterService } from '../../interpreter/contracts' ;
2922import { captureTelemetry , sendTelemetryEvent } from '../../telemetry' ;
3023import { concatMultilineString } from '../common' ;
31- import {
32- EditorContexts ,
33- Identifiers ,
34- NativeKeyboardCommandTelemetryLookup ,
35- NativeMouseCommandTelemetryLookup ,
36- Telemetry
37- } from '../constants' ;
24+ import { EditorContexts , Identifiers , NativeKeyboardCommandTelemetryLookup , NativeMouseCommandTelemetryLookup , Telemetry } from '../constants' ;
3825import { InteractiveBase } from '../interactive-common/interactiveBase' ;
39- import {
40- IEditCell ,
41- INativeCommand ,
42- InteractiveWindowMessages ,
43- ISaveAll ,
44- ISubmitNewCell
45- } from '../interactive-common/interactiveWindowTypes' ;
26+ import { IEditCell , INativeCommand , InteractiveWindowMessages , ISaveAll , ISubmitNewCell } from '../interactive-common/interactiveWindowTypes' ;
4627import {
4728 CellState ,
4829 ICell ,
@@ -74,6 +55,7 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
7455 private closedEvent : EventEmitter < INotebookEditor > = new EventEmitter < INotebookEditor > ( ) ;
7556 private executedEvent : EventEmitter < INotebookEditor > = new EventEmitter < INotebookEditor > ( ) ;
7657 private modifiedEvent : EventEmitter < INotebookEditor > = new EventEmitter < INotebookEditor > ( ) ;
58+ private savedEvent : EventEmitter < INotebookEditor > = new EventEmitter < INotebookEditor > ( ) ;
7759 private loadedPromise : Deferred < void > = createDeferred < void > ( ) ;
7860 private _file : Uri = Uri . file ( '' ) ;
7961 private _dirty : boolean = false ;
@@ -129,7 +111,8 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
129111 errorHandler ,
130112 path . join ( EXTENSION_ROOT_DIR , 'out' , 'datascience-ui' , 'native-editor' , 'index_bundle.js' ) ,
131113 localize . DataScience . nativeEditorTitle ( ) ,
132- ViewColumn . Active ) ;
114+ ViewColumn . Active
115+ ) ;
133116 }
134117
135118 public get visible ( ) : boolean {
@@ -187,6 +170,14 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
187170 return this . modifiedEvent . event ;
188171 }
189172
173+ public get saved ( ) : Event < INotebookEditor > {
174+ return this . savedEvent . event ;
175+ }
176+
177+ public get isDirty ( ) : boolean {
178+ return this . _dirty ;
179+ }
180+
190181 // tslint:disable-next-line: no-any
191182 public onMessage ( message : string , payload : any ) {
192183 super . onMessage ( message , payload ) ;
@@ -269,9 +260,19 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
269260 this . submitCode ( info . code , Identifiers . EmptyFileName , 0 , info . id ) . ignoreErrors ( ) ;
270261
271262 // Activate the other side, and send as if came from a file
272- this . ipynbProvider . show ( this . file ) . then ( _v => {
273- this . shareMessage ( InteractiveWindowMessages . RemoteAddCode , { code : info . code , file : Identifiers . EmptyFileName , line : 0 , id : info . id , originator : this . id , debug : false } ) ;
274- } ) . ignoreErrors ( ) ;
263+ this . ipynbProvider
264+ . show ( this . file )
265+ . then ( _v => {
266+ this . shareMessage ( InteractiveWindowMessages . RemoteAddCode , {
267+ code : info . code ,
268+ file : Identifiers . EmptyFileName ,
269+ line : 0 ,
270+ id : info . id ,
271+ originator : this . id ,
272+ debug : false
273+ } ) ;
274+ } )
275+ . ignoreErrors ( ) ;
275276 }
276277 }
277278
@@ -289,7 +290,14 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
289290
290291 // Activate the other side, and send as if came from a file
291292 await this . ipynbProvider . show ( this . file ) ;
292- this . shareMessage ( InteractiveWindowMessages . RemoteReexecuteCode , { code : info . code , file : Identifiers . EmptyFileName , line : 0 , id : info . id , originator : this . id , debug : false } ) ;
293+ this . shareMessage ( InteractiveWindowMessages . RemoteReexecuteCode , {
294+ code : info . code ,
295+ file : Identifiers . EmptyFileName ,
296+ line : 0 ,
297+ id : info . id ,
298+ originator : this . id ,
299+ debug : false
300+ } ) ;
293301 }
294302 } catch ( exc ) {
295303 // Make this error our cell output
@@ -298,10 +306,12 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
298306 data : {
299307 source : info . code ,
300308 cell_type : 'code' ,
301- outputs : [ {
302- output_type : 'error' ,
303- evalue : exc . toString ( )
304- } ] ,
309+ outputs : [
310+ {
311+ output_type : 'error' ,
312+ evalue : exc . toString ( )
313+ }
314+ ] ,
305315 metadata : { } ,
306316 execution_count : null
307317 } ,
@@ -318,7 +328,6 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
318328
319329 // Handle an error
320330 await this . errorHandler . handleError ( exc ) ;
321-
322331 }
323332 }
324333
@@ -395,8 +404,7 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
395404 cell_type : 'code' ,
396405 outputs : [ ] ,
397406 source : [ ] ,
398- metadata : {
399- } ,
407+ metadata : { } ,
400408 execution_count : null
401409 }
402410 } ;
@@ -570,7 +578,6 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
570578 if ( contents ) {
571579 await this . viewDocument ( contents ) ;
572580 }
573-
574581 } catch ( e ) {
575582 await this . errorHandler . handleError ( e ) ;
576583 } finally {
@@ -615,8 +622,8 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
615622 // Update our file name and dirty state
616623 this . _file = fileToSaveTo ;
617624 await this . setClean ( ) ;
625+ this . savedEvent . fire ( this ) ;
618626 }
619-
620627 } catch ( e ) {
621628 traceError ( e ) ;
622629 }
0 commit comments