@@ -31,6 +31,7 @@ import { FileKind } from 'vs/platform/files/common/files';
31
31
import { IModelService } from 'vs/editor/common/services/model' ;
32
32
import { EditOperation } from 'vs/editor/common/core/editOperation' ;
33
33
import { Session } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession' ;
34
+ import { ILanguageService } from 'vs/editor/common/languages/language' ;
34
35
35
36
export class InlineChatLivePreviewWidget extends ZoneWidget {
36
37
@@ -349,6 +350,7 @@ export class InlineChatFileCreatePreviewWidget extends ZoneWidget {
349
350
constructor (
350
351
parentEditor : ICodeEditor ,
351
352
@IInstantiationService instaService : IInstantiationService ,
353
+ @ILanguageService private readonly _languageService : ILanguageService ,
352
354
@IModelService private readonly _modelService : IModelService ,
353
355
@IThemeService themeService : IThemeService ,
354
356
@@ -401,8 +403,8 @@ export class InlineChatFileCreatePreviewWidget extends ZoneWidget {
401
403
showCreation ( where : Range , uri : URI , edits : TextEdit [ ] ) : void {
402
404
403
405
this . _title . element . setFile ( uri , { fileKind : FileKind . FILE } ) ;
404
-
405
- const model = this . _modelService . createModel ( '' , null , undefined , true ) ;
406
+ const langSelection = this . _languageService . createByFilepathOrFirstLine ( uri , undefined ) ;
407
+ const model = this . _modelService . createModel ( '' , langSelection , undefined , true ) ;
406
408
model . applyEdits ( edits . map ( edit => EditOperation . replace ( Range . lift ( edit . range ) , edit . text ) ) ) ;
407
409
this . _previewModel . value = model ;
408
410
this . _previewEditor . setModel ( model ) ;
0 commit comments