@@ -8,6 +8,7 @@ import { IReference } from 'vs/base/common/lifecycle';
8
8
import * as paths from 'vs/base/common/path' ;
9
9
import { isEqual , joinPath } from 'vs/base/common/resources' ;
10
10
import { URI } from 'vs/base/common/uri' ;
11
+ import { PLAINTEXT_LANGUAGE_ID } from 'vs/editor/common/languages/modesRegistry' ;
11
12
import { IResolvedTextEditorModel , ITextModelService } from 'vs/editor/common/services/resolverService' ;
12
13
import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs' ;
13
14
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
@@ -20,8 +21,8 @@ import { ICompositeNotebookEditorInput, NotebookEditorInput } from 'vs/workbench
20
21
import { INotebookService } from 'vs/workbench/contrib/notebook/common/notebookService' ;
21
22
22
23
export class InteractiveEditorInput extends EditorInput implements ICompositeNotebookEditorInput {
23
- static create ( instantiationService : IInstantiationService , resource : URI , inputResource : URI , title ?: string ) {
24
- return instantiationService . createInstance ( InteractiveEditorInput , resource , inputResource , title ) ;
24
+ static create ( instantiationService : IInstantiationService , resource : URI , inputResource : URI , title ?: string , language ?: string ) {
25
+ return instantiationService . createInstance ( InteractiveEditorInput , resource , inputResource , title , language ) ;
25
26
}
26
27
27
28
static readonly ID : string = 'workbench.input.interactive' ;
@@ -36,6 +37,11 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
36
37
37
38
private _initTitle ?: string ;
38
39
40
+ get language ( ) {
41
+ return this . _inputModelRef ?. object . textEditorModel . getLanguageId ( ) ?? this . _initLanguage ;
42
+ }
43
+ private _initLanguage ?: string ;
44
+
39
45
private _notebookEditorInput : NotebookEditorInput ;
40
46
get notebookEditorInput ( ) {
41
47
return this . _notebookEditorInput ;
@@ -73,6 +79,7 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
73
79
resource : URI ,
74
80
inputResource : URI ,
75
81
title : string | undefined ,
82
+ languageId : string | undefined ,
76
83
@IInstantiationService instantiationService : IInstantiationService ,
77
84
@ITextModelService textModelService : ITextModelService ,
78
85
@IInteractiveDocumentService interactiveDocumentService : IInteractiveDocumentService ,
@@ -85,6 +92,7 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
85
92
this . _notebookEditorInput = input ;
86
93
this . _register ( this . _notebookEditorInput ) ;
87
94
this . _initTitle = title ;
95
+ this . _initLanguage = languageId ;
88
96
this . _resource = resource ;
89
97
this . _inputResource = inputResource ;
90
98
this . _inputResolver = null ;
@@ -141,12 +149,13 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot
141
149
return this . _inputResolver ;
142
150
}
143
151
144
- async resolveInput ( language : string ) {
152
+ async resolveInput ( language ? : string ) {
145
153
if ( this . _inputModelRef ) {
146
154
return this . _inputModelRef . object . textEditorModel ;
147
155
}
148
156
149
- this . _interactiveDocumentService . willCreateInteractiveDocument ( this . resource ! , this . inputResource , language ) ;
157
+ const resolvedLanguage = language ?? this . _initLanguage ?? PLAINTEXT_LANGUAGE_ID ;
158
+ this . _interactiveDocumentService . willCreateInteractiveDocument ( this . resource ! , this . inputResource , resolvedLanguage ) ;
150
159
this . _inputModelRef = await this . _textModelService . createModelReference ( this . inputResource ) ;
151
160
152
161
return this . _inputModelRef . object . textEditorModel ;
0 commit comments