From 56d97f50ba105a5eb6ba991ce6b6476722073f12 Mon Sep 17 00:00:00 2001 From: "opensumi[bot]" <99156626+opensumi[bot]@users.noreply.github.com> Date: Thu, 14 Mar 2024 15:46:18 +0800 Subject: [PATCH] fix: 3way merge result model save error (#3403) Co-authored-by: qingyi.xjh --- .../contrib/merge-editor/merge-editor-widget.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/monaco/src/browser/contrib/merge-editor/merge-editor-widget.tsx b/packages/monaco/src/browser/contrib/merge-editor/merge-editor-widget.tsx index 9a1111c028..8a03f158be 100644 --- a/packages/monaco/src/browser/contrib/merge-editor/merge-editor-widget.tsx +++ b/packages/monaco/src/browser/contrib/merge-editor/merge-editor-widget.tsx @@ -4,7 +4,7 @@ import ReactDOM from 'react-dom/client'; import { Autowired, Injectable } from '@opensumi/di'; import { AppConfig, ConfigProvider } from '@opensumi/ide-core-browser'; import { IMergeEditorEditor, IOpenMergeEditorArgs } from '@opensumi/ide-core-browser/lib/monaco/merge-editor-widget'; -import { Disposable, IRange, ISelection, URI } from '@opensumi/ide-core-common'; +import { Disposable, Event, IRange, ISelection, URI } from '@opensumi/ide-core-common'; import { Selection } from '@opensumi/monaco-editor-core'; import { IDisposable } from '@opensumi/monaco-editor-core/esm/vs/base/common/lifecycle'; import { IDimension } from '@opensumi/monaco-editor-core/esm/vs/editor/common/core/dimension'; @@ -15,9 +15,12 @@ import { IEditorViewState, ScrollType, } from '@opensumi/monaco-editor-core/esm/vs/editor/common/editorCommon'; +import { ILanguageSelection } from '@opensumi/monaco-editor-core/esm/vs/editor/common/languages/language'; import { IModelDecorationsChangeAccessor, ITextModel } from '@opensumi/monaco-editor-core/esm/vs/editor/common/model'; +import { IModelService } from '@opensumi/monaco-editor-core/esm/vs/editor/common/services/model'; import { ICodeEditor, IDiffEditorOptions, IEditorOptions, IModelDeltaDecoration } from '../../monaco-api/editor'; +import { StandaloneServices } from '../../monaco-api/services'; import { IPosition, Position } from '../../monaco-api/types'; import { MergeEditorService } from './merge-editor.service'; @@ -89,9 +92,16 @@ export class MergeEditorWidget extends Disposable implements IMergeEditorEditor this.outputUri = output.uri; const uniqueKey = this.outputUri.toString(); + const modelService = StandaloneServices.get(IModelService); + const languageSelection: ILanguageSelection = { + languageId: (ancestor.textModel as ITextModel).getLanguageId(), + onDidChange: Event.None, + }; + const ancestorModel = modelService.createModel(ancestor.baseContent, languageSelection); + this.setModel({ ours: input1.textModel as ITextModel, - result: ancestor.textModel as ITextModel, + result: ancestorModel, theirs: input2.textModel as ITextModel, });