@@ -37,6 +37,7 @@ import { PLAINTEXT_LANGUAGE_ID } from 'vs/editor/common/languages/modesRegistry'
37
37
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry' ;
38
38
import { IEditorConstructionOptions } from 'vs/editor/browser/config/editorConfiguration' ;
39
39
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures' ;
40
+ import { DiffEditorWidget2 } from 'vs/editor/browser/widget/diffEditorWidget2/diffEditorWidget2' ;
40
41
41
42
/**
42
43
* Description of an action contribution
@@ -555,6 +556,89 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon
555
556
}
556
557
}
557
558
559
+ export class StandaloneDiffEditor2 extends DiffEditorWidget2 implements IStandaloneDiffEditor {
560
+
561
+ private readonly _configurationService : IConfigurationService ;
562
+ private readonly _standaloneThemeService : IStandaloneThemeService ;
563
+
564
+ constructor (
565
+ domElement : HTMLElement ,
566
+ _options : Readonly < IStandaloneDiffEditorConstructionOptions > | undefined ,
567
+ @IInstantiationService instantiationService : IInstantiationService ,
568
+ @IContextKeyService contextKeyService : IContextKeyService ,
569
+ @ICodeEditorService codeEditorService : ICodeEditorService ,
570
+ @IStandaloneThemeService themeService : IStandaloneThemeService ,
571
+ @INotificationService notificationService : INotificationService ,
572
+ @IConfigurationService configurationService : IConfigurationService ,
573
+ @IContextMenuService contextMenuService : IContextMenuService ,
574
+ @IEditorProgressService editorProgressService : IEditorProgressService ,
575
+ @IClipboardService clipboardService : IClipboardService
576
+ ) {
577
+ const options = { ..._options } ;
578
+ updateConfigurationService ( configurationService , options , true ) ;
579
+ const themeDomRegistration = ( < StandaloneThemeService > themeService ) . registerEditorContainer ( domElement ) ;
580
+ if ( typeof options . theme === 'string' ) {
581
+ themeService . setTheme ( options . theme ) ;
582
+ }
583
+ if ( typeof options . autoDetectHighContrast !== 'undefined' ) {
584
+ themeService . setAutoDetectHighContrast ( Boolean ( options . autoDetectHighContrast ) ) ;
585
+ }
586
+
587
+ super (
588
+ domElement ,
589
+ options ,
590
+ { } ,
591
+ contextKeyService ,
592
+ instantiationService ,
593
+ codeEditorService ,
594
+ ) ;
595
+
596
+ this . _configurationService = configurationService ;
597
+ this . _standaloneThemeService = themeService ;
598
+
599
+ this . _register ( themeDomRegistration ) ;
600
+ }
601
+
602
+ public override dispose ( ) : void {
603
+ super . dispose ( ) ;
604
+ }
605
+
606
+ public override updateOptions ( newOptions : Readonly < IDiffEditorOptions & IGlobalEditorOptions > ) : void {
607
+ updateConfigurationService ( this . _configurationService , newOptions , true ) ;
608
+ if ( typeof newOptions . theme === 'string' ) {
609
+ this . _standaloneThemeService . setTheme ( newOptions . theme ) ;
610
+ }
611
+ if ( typeof newOptions . autoDetectHighContrast !== 'undefined' ) {
612
+ this . _standaloneThemeService . setAutoDetectHighContrast ( Boolean ( newOptions . autoDetectHighContrast ) ) ;
613
+ }
614
+ super . updateOptions ( newOptions ) ;
615
+ }
616
+
617
+ protected override _createInnerEditor ( instantiationService : IInstantiationService , container : HTMLElement , options : Readonly < IEditorOptions > ) : CodeEditorWidget {
618
+ return instantiationService . createInstance ( StandaloneCodeEditor , container , options ) ;
619
+ }
620
+
621
+ public override getOriginalEditor ( ) : IStandaloneCodeEditor {
622
+ return < StandaloneCodeEditor > super . getOriginalEditor ( ) ;
623
+ }
624
+
625
+ public override getModifiedEditor ( ) : IStandaloneCodeEditor {
626
+ return < StandaloneCodeEditor > super . getModifiedEditor ( ) ;
627
+ }
628
+
629
+ public addCommand ( keybinding : number , handler : ICommandHandler , context ?: string ) : string | null {
630
+ return this . getModifiedEditor ( ) . addCommand ( keybinding , handler , context ) ;
631
+ }
632
+
633
+ public createContextKey < T extends ContextKeyValue = ContextKeyValue > ( key : string , defaultValue : T ) : IContextKey < T > {
634
+ return this . getModifiedEditor ( ) . createContextKey ( key , defaultValue ) ;
635
+ }
636
+
637
+ public addAction ( descriptor : IActionDescriptor ) : IDisposable {
638
+ return this . getModifiedEditor ( ) . addAction ( descriptor ) ;
639
+ }
640
+ }
641
+
558
642
/**
559
643
* @internal
560
644
*/
0 commit comments