@@ -11,7 +11,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
1111import { IEditorInput } from 'vs/workbench/common/editor' ;
1212import { CustomEditorInput } from 'vs/workbench/contrib/customEditor/browser/customEditorInput' ;
1313import { IWebviewService } from 'vs/workbench/contrib/webview/browser/webview' ;
14- import { WebviewEditorInputFactory } from 'vs/workbench/contrib/webview/browser/webviewEditorInputFactory' ;
14+ import { WebviewEditorInputFactory , SerializedWebview } from 'vs/workbench/contrib/webview/browser/webviewEditorInputFactory' ;
1515import { IWebviewWorkbenchService , WebviewInputOptions } from 'vs/workbench/contrib/webview/browser/webviewWorkbenchService' ;
1616import { IBackupFileService } from 'vs/workbench/services/backup/common/backup' ;
1717
@@ -30,6 +30,12 @@ export interface CustomDocumentBackupData {
3030 } ;
3131}
3232
33+ interface SerializedCustomEditor extends SerializedWebview {
34+ readonly editorResource : UriComponents ;
35+ readonly dirty ?: boolean ;
36+ }
37+
38+
3339export class CustomEditorInputFactory extends WebviewEditorInputFactory {
3440
3541 public static readonly ID = CustomEditorInput . typeId ;
@@ -43,9 +49,10 @@ export class CustomEditorInputFactory extends WebviewEditorInputFactory {
4349 }
4450
4551 public serialize ( input : CustomEditorInput ) : string | undefined {
46- const data = {
52+ const data : SerializedCustomEditor = {
4753 ...this . toJson ( input ) ,
4854 editorResource : input . resource . toJSON ( ) ,
55+ dirty : input . isDirty ( ) ,
4956 } ;
5057
5158 try {
@@ -78,7 +85,7 @@ export class CustomEditorInputFactory extends WebviewEditorInputFactory {
7885 return webview ;
7986 } ) ;
8087
81- const customInput = this . _instantiationService . createInstance ( CustomEditorInput , URI . from ( ( data as any ) . editorResource ) , data . viewType , id , webview , false ) ;
88+ const customInput = this . _instantiationService . createInstance ( CustomEditorInput , URI . from ( ( data as any ) . editorResource ) , data . viewType , id , webview , { startsDirty : ( data as any ) . dirty } ) ;
8289 if ( typeof data . group === 'number' ) {
8390 customInput . updateGroup ( data . group ) ;
8491 }
@@ -112,7 +119,7 @@ export class CustomEditorInputFactory extends WebviewEditorInputFactory {
112119 return webview ;
113120 } ) ;
114121
115- const editor = instantiationService . createInstance ( CustomEditorInput , URI . revive ( backupData . editorResource ) , backupData . viewType , id , webview , true ) ;
122+ const editor = instantiationService . createInstance ( CustomEditorInput , URI . revive ( backupData . editorResource ) , backupData . viewType , id , webview , { startsDirty : true } ) ;
116123 editor . updateGroup ( 0 ) ;
117124 return editor ;
118125 } ) ;
0 commit comments