@@ -46,6 +46,7 @@ export class SimpleNotebookEditorModel extends EditorModel implements INotebookE
46
46
private _workingCopy ?: IStoredFileWorkingCopy < NotebookFileWorkingCopyModel > | IUntitledFileWorkingCopy < NotebookFileWorkingCopyModel > ;
47
47
private readonly _workingCopyListeners = this . _register ( new DisposableStore ( ) ) ;
48
48
private readonly scratchPad : boolean ;
49
+ private _hasErrorState : boolean = false ;
49
50
50
51
constructor (
51
52
readonly resource : URI ,
@@ -108,6 +109,10 @@ export class SimpleNotebookEditorModel extends EditorModel implements INotebookE
108
109
}
109
110
}
110
111
112
+ get hasErrorState ( ) : boolean {
113
+ return this . _hasErrorState ;
114
+ }
115
+
111
116
revert ( options ?: IRevertOptions ) : Promise < void > {
112
117
assertType ( this . isResolved ( ) ) ;
113
118
return this . _workingCopy ! . revert ( options ) ;
@@ -118,6 +123,13 @@ export class SimpleNotebookEditorModel extends EditorModel implements INotebookE
118
123
return this . _workingCopy ! . save ( options ) ;
119
124
}
120
125
126
+ private onDidChangeDirtyHandler ( ) {
127
+ if ( ! this . _workingCopy ?. isDirty ( ) ) {
128
+ this . _hasErrorState = false ;
129
+ }
130
+ this . _onDidChangeDirty . fire ( ) ;
131
+ }
132
+
121
133
async load ( options ?: INotebookLoadOptions ) : Promise < IResolvedNotebookEditorModel > {
122
134
if ( ! this . _workingCopy || ! this . _workingCopy . model ) {
123
135
if ( this . resource . scheme === Schemas . untitled ) {
@@ -132,8 +144,9 @@ export class SimpleNotebookEditorModel extends EditorModel implements INotebookE
132
144
this . _workingCopyListeners . add ( this . _workingCopy . onDidSave ( e => this . _onDidSave . fire ( e ) ) ) ;
133
145
this . _workingCopyListeners . add ( this . _workingCopy . onDidChangeOrphaned ( ( ) => this . _onDidChangeOrphaned . fire ( ) ) ) ;
134
146
this . _workingCopyListeners . add ( this . _workingCopy . onDidChangeReadonly ( ( ) => this . _onDidChangeReadonly . fire ( ) ) ) ;
147
+ this . _workingCopyListeners . add ( this . _workingCopy . onDidSaveError ( ( ) => { this . _hasErrorState = true ; } ) ) ;
135
148
}
136
- this . _workingCopy . onDidChangeDirty ( ( ) => this . _onDidChangeDirty . fire ( ) , undefined , this . _workingCopyListeners ) ;
149
+ this . _workingCopyListeners . add ( this . _workingCopy . onDidChangeDirty ( this . onDidChangeDirtyHandler . bind ( this ) , undefined , this . _workingCopyListeners ) ) ;
137
150
138
151
this . _workingCopyListeners . add ( this . _workingCopy . onWillDispose ( ( ) => {
139
152
this . _workingCopyListeners . clear ( ) ;
0 commit comments