@@ -24,6 +24,7 @@ import { peekViewBorder /*, peekViewEditorBackground, peekViewResultsBackground
24
24
import { Context as SuggestContext } from 'vs/editor/contrib/suggest/browser/suggest' ;
25
25
import { localize } from 'vs/nls' ;
26
26
import { Action2 , MenuId , registerAction2 } from 'vs/platform/actions/common/actions' ;
27
+ import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
27
28
import { IConfigurationRegistry , Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry' ;
28
29
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey' ;
29
30
import { EditorActivation , IResourceEditorInput } from 'vs/platform/editor/common/editor' ;
@@ -38,12 +39,12 @@ import { contrastBorder, listInactiveSelectionBackground, registerColor, transpa
38
39
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService' ;
39
40
import { EditorPaneDescriptor , IEditorPaneRegistry } from 'vs/workbench/browser/editor' ;
40
41
import { Extensions as WorkbenchExtensions , IWorkbenchContribution , IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions' ;
41
- import { EditorExtensions , EditorsOrder , IEditorSerializer } from 'vs/workbench/common/editor' ;
42
+ import { EditorExtensions , EditorsOrder , IEditorFactoryRegistry , IEditorSerializer } from 'vs/workbench/common/editor' ;
42
43
import { EditorInput } from 'vs/workbench/common/editor/editorInput' ;
43
44
// import { Color } from 'vs/base/common/color';
44
45
import { PANEL_BORDER } from 'vs/workbench/common/theme' ;
45
46
import { ResourceNotebookCellEdit } from 'vs/workbench/contrib/bulkEdit/browser/bulkCellEdits' ;
46
- import { INTERACTIVE_INPUT_CURSOR_BOUNDARY } from 'vs/workbench/contrib/interactive/browser/interactiveCommon' ;
47
+ import { InteractiveWindowSetting , INTERACTIVE_INPUT_CURSOR_BOUNDARY } from 'vs/workbench/contrib/interactive/browser/interactiveCommon' ;
47
48
import { IInteractiveDocumentService , InteractiveDocumentService } from 'vs/workbench/contrib/interactive/browser/interactiveDocumentService' ;
48
49
import { InteractiveEditor } from 'vs/workbench/contrib/interactive/browser/interactiveEditor' ;
49
50
import { InteractiveEditorInput } from 'vs/workbench/contrib/interactive/browser/interactiveEditorInput' ;
@@ -52,7 +53,7 @@ import { NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT } from 'vs/workbench/contrib/noteb
52
53
import { INotebookEditorOptions } from 'vs/workbench/contrib/notebook/browser/notebookBrowser' ;
53
54
import { NotebookEditorWidget } from 'vs/workbench/contrib/notebook/browser/notebookEditorWidget' ;
54
55
import * as icons from 'vs/workbench/contrib/notebook/browser/notebookIcons' ;
55
- import { CellEditType , CellKind , CellUri , ICellOutput , NotebookSetting } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
56
+ import { CellEditType , CellKind , CellUri , ICellOutput } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
56
57
import { INotebookKernelService } from 'vs/workbench/contrib/notebook/common/notebookKernelService' ;
57
58
import { INotebookContentProvider , INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService' ;
58
59
import { columnToEditorGroup } from 'vs/workbench/services/editor/common/editorGroupColumn' ;
@@ -194,7 +195,7 @@ export class InteractiveDocumentContribution extends Disposable implements IWork
194
195
editorResolverService . registerEditor (
195
196
`${ Schemas . vscodeInteractiveInput } :/**` ,
196
197
{
197
- id : InteractiveEditorInput . ID ,
198
+ id : 'vscode-interactive-input' ,
198
199
label : 'Interactive Editor' ,
199
200
priority : RegisteredEditorPriority . exclusive
200
201
} ,
@@ -211,7 +212,7 @@ export class InteractiveDocumentContribution extends Disposable implements IWork
211
212
editorResolverService . registerEditor (
212
213
`*.interactive` ,
213
214
{
214
- id : InteractiveEditorInput . ID ,
215
+ id : 'interactive' ,
215
216
label : 'Interactive Editor' ,
216
217
priority : RegisteredEditorPriority . exclusive
217
218
} ,
@@ -272,20 +273,30 @@ workbenchContributionsRegistry.registerWorkbenchContribution(InteractiveDocument
272
273
workbenchContributionsRegistry . registerWorkbenchContribution ( InteractiveInputContentProvider , LifecyclePhase . Starting ) ;
273
274
274
275
export class InteractiveEditorSerializer implements IEditorSerializer {
276
+ public static readonly ID = InteractiveEditorInput . ID ;
277
+
278
+ constructor ( @IConfigurationService private configurationService : IConfigurationService ) {
279
+ }
280
+
275
281
canSerialize ( ) : boolean {
276
- return true ;
282
+ return this . configurationService . getValue < boolean > ( InteractiveWindowSetting . interactiveWindowHotExit ) ;
277
283
}
278
284
279
285
serialize ( input : EditorInput ) : string {
280
286
assertType ( input instanceof InteractiveEditorInput ) ;
281
287
return JSON . stringify ( {
282
288
resource : input . primary . resource ,
283
289
inputResource : input . inputResource ,
290
+ name : input . getName ( ) ,
291
+ data : input . getSerialization ( )
284
292
} ) ;
285
293
}
286
294
287
295
deserialize ( instantiationService : IInstantiationService , raw : string ) {
288
- type Data = { resource : URI ; inputResource : URI } ;
296
+ if ( ! this . canSerialize ( ) ) {
297
+ return undefined ;
298
+ }
299
+ type Data = { resource : URI ; inputResource : URI ; data : any } ;
289
300
const data = < Data > parse ( raw ) ;
290
301
if ( ! data ) {
291
302
return undefined ;
@@ -296,14 +307,15 @@ export class InteractiveEditorSerializer implements IEditorSerializer {
296
307
}
297
308
298
309
const input = InteractiveEditorInput . create ( instantiationService , resource , inputResource ) ;
310
+ input . restoreSerialization ( data . data ) ;
299
311
return input ;
300
312
}
301
313
}
302
314
303
- // Registry.as<EditorInputFactoryRegistry >(EditorExtensions.EditorInputFactories).registerEditorInputSerializer(
304
- // InteractiveEditorInput.ID,
305
- // InteractiveEditorSerializer
306
- // );
315
+ Registry . as < IEditorFactoryRegistry > ( EditorExtensions . EditorFactory )
316
+ . registerEditorSerializer (
317
+ InteractiveEditorSerializer . ID ,
318
+ InteractiveEditorSerializer ) ;
307
319
308
320
registerSingleton ( IInteractiveHistoryService , InteractiveHistoryService ) ;
309
321
registerSingleton ( IInteractiveDocumentService , InteractiveDocumentService ) ;
@@ -738,15 +750,20 @@ registerThemingParticipant((theme) => {
738
750
} ) ;
739
751
740
752
Registry . as < IConfigurationRegistry > ( ConfigurationExtensions . Configuration ) . registerConfiguration ( {
741
- id : 'notebook ' ,
753
+ id : 'interactiveWindow ' ,
742
754
order : 100 ,
743
755
type : 'object' ,
744
756
'properties' : {
745
- [ NotebookSetting . interactiveWindowAlwaysScrollOnNewCell ] : {
757
+ [ InteractiveWindowSetting . interactiveWindowAlwaysScrollOnNewCell ] : {
746
758
type : 'boolean' ,
747
759
default : true ,
748
760
markdownDescription : localize ( 'interactiveWindow.alwaysScrollOnNewCell' , "Automatically scroll the interactive window to show the output of the last statement executed. If this value is false, the window will only scroll if the last cell was already the one scrolled to." )
749
761
} ,
762
+ [ InteractiveWindowSetting . interactiveWindowHotExit ] : {
763
+ type : 'boolean' ,
764
+ default : false ,
765
+ markdownDescription : localize ( 'interactiveWindow.hotExit' , "Controls whether the interactive window sessions should be restored when the workspace reloads." )
766
+ }
750
767
}
751
768
} ) ;
752
769
0 commit comments