mirror of
https://github.com/Microsoft/vscode
synced 2024-10-06 03:17:00 +00:00
Make new diff editor available in monaco (with experimental.useVersion2: true)
This commit is contained in:
parent
6d45c3610a
commit
bbb579918b
|
@ -37,6 +37,7 @@ import { PLAINTEXT_LANGUAGE_ID } from 'vs/editor/common/languages/modesRegistry'
|
|||
import { ILanguageConfigurationService } from 'vs/editor/common/languages/languageConfigurationRegistry';
|
||||
import { IEditorConstructionOptions } from 'vs/editor/browser/config/editorConfiguration';
|
||||
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
|
||||
import { DiffEditorWidget2 } from 'vs/editor/browser/widget/diffEditorWidget2/diffEditorWidget2';
|
||||
|
||||
/**
|
||||
* Description of an action contribution
|
||||
|
@ -555,6 +556,89 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon
|
|||
}
|
||||
}
|
||||
|
||||
export class StandaloneDiffEditor2 extends DiffEditorWidget2 implements IStandaloneDiffEditor {
|
||||
|
||||
private readonly _configurationService: IConfigurationService;
|
||||
private readonly _standaloneThemeService: IStandaloneThemeService;
|
||||
|
||||
constructor(
|
||||
domElement: HTMLElement,
|
||||
_options: Readonly<IStandaloneDiffEditorConstructionOptions> | undefined,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@ICodeEditorService codeEditorService: ICodeEditorService,
|
||||
@IStandaloneThemeService themeService: IStandaloneThemeService,
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IContextMenuService contextMenuService: IContextMenuService,
|
||||
@IEditorProgressService editorProgressService: IEditorProgressService,
|
||||
@IClipboardService clipboardService: IClipboardService
|
||||
) {
|
||||
const options = { ..._options };
|
||||
updateConfigurationService(configurationService, options, true);
|
||||
const themeDomRegistration = (<StandaloneThemeService>themeService).registerEditorContainer(domElement);
|
||||
if (typeof options.theme === 'string') {
|
||||
themeService.setTheme(options.theme);
|
||||
}
|
||||
if (typeof options.autoDetectHighContrast !== 'undefined') {
|
||||
themeService.setAutoDetectHighContrast(Boolean(options.autoDetectHighContrast));
|
||||
}
|
||||
|
||||
super(
|
||||
domElement,
|
||||
options,
|
||||
{},
|
||||
contextKeyService,
|
||||
instantiationService,
|
||||
codeEditorService,
|
||||
);
|
||||
|
||||
this._configurationService = configurationService;
|
||||
this._standaloneThemeService = themeService;
|
||||
|
||||
this._register(themeDomRegistration);
|
||||
}
|
||||
|
||||
public override dispose(): void {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public override updateOptions(newOptions: Readonly<IDiffEditorOptions & IGlobalEditorOptions>): void {
|
||||
updateConfigurationService(this._configurationService, newOptions, true);
|
||||
if (typeof newOptions.theme === 'string') {
|
||||
this._standaloneThemeService.setTheme(newOptions.theme);
|
||||
}
|
||||
if (typeof newOptions.autoDetectHighContrast !== 'undefined') {
|
||||
this._standaloneThemeService.setAutoDetectHighContrast(Boolean(newOptions.autoDetectHighContrast));
|
||||
}
|
||||
super.updateOptions(newOptions);
|
||||
}
|
||||
|
||||
protected override _createInnerEditor(instantiationService: IInstantiationService, container: HTMLElement, options: Readonly<IEditorOptions>): CodeEditorWidget {
|
||||
return instantiationService.createInstance(StandaloneCodeEditor, container, options);
|
||||
}
|
||||
|
||||
public override getOriginalEditor(): IStandaloneCodeEditor {
|
||||
return <StandaloneCodeEditor>super.getOriginalEditor();
|
||||
}
|
||||
|
||||
public override getModifiedEditor(): IStandaloneCodeEditor {
|
||||
return <StandaloneCodeEditor>super.getModifiedEditor();
|
||||
}
|
||||
|
||||
public addCommand(keybinding: number, handler: ICommandHandler, context?: string): string | null {
|
||||
return this.getModifiedEditor().addCommand(keybinding, handler, context);
|
||||
}
|
||||
|
||||
public createContextKey<T extends ContextKeyValue = ContextKeyValue>(key: string, defaultValue: T): IContextKey<T> {
|
||||
return this.getModifiedEditor().createContextKey(key, defaultValue);
|
||||
}
|
||||
|
||||
public addAction(descriptor: IActionDescriptor): IDisposable {
|
||||
return this.getModifiedEditor().addAction(descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
|
|
|
@ -23,7 +23,7 @@ import { IModelService } from 'vs/editor/common/services/model';
|
|||
import { createWebWorker as actualCreateWebWorker, IWebWorkerOptions, MonacoWebWorker } from 'vs/editor/browser/services/webWorker';
|
||||
import * as standaloneEnums from 'vs/editor/common/standalone/standaloneEnums';
|
||||
import { Colorizer, IColorizerElementOptions, IColorizerOptions } from 'vs/editor/standalone/browser/colorizer';
|
||||
import { createTextModel, IActionDescriptor, IStandaloneCodeEditor, IStandaloneDiffEditor, IStandaloneDiffEditorConstructionOptions, IStandaloneEditorConstructionOptions, StandaloneDiffEditor, StandaloneEditor } from 'vs/editor/standalone/browser/standaloneCodeEditor';
|
||||
import { createTextModel, IActionDescriptor, IStandaloneCodeEditor, IStandaloneDiffEditor, IStandaloneDiffEditorConstructionOptions, IStandaloneEditorConstructionOptions, StandaloneDiffEditor, StandaloneDiffEditor2, StandaloneEditor } from 'vs/editor/standalone/browser/standaloneCodeEditor';
|
||||
import { IEditorOverrideServices, StandaloneKeybindingService, StandaloneServices } from 'vs/editor/standalone/browser/standaloneServices';
|
||||
import { StandaloneThemeService } from 'vs/editor/standalone/browser/standaloneThemeService';
|
||||
import { IStandaloneThemeData, IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneTheme';
|
||||
|
@ -98,6 +98,9 @@ export function getDiffEditors(): readonly IDiffEditor[] {
|
|||
*/
|
||||
export function createDiffEditor(domElement: HTMLElement, options?: IStandaloneDiffEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneDiffEditor {
|
||||
const instantiationService = StandaloneServices.initialize(override || {});
|
||||
if ((options?.experimental as any)?.useVersion2) {
|
||||
return instantiationService.createInstance(StandaloneDiffEditor2, domElement, options);
|
||||
}
|
||||
return instantiationService.createInstance(StandaloneDiffEditor, domElement, options);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue