diff --git a/packages/editor/src/browser/doc-model/editor-document-model.ts b/packages/editor/src/browser/doc-model/editor-document-model.ts index 62616b6d54..18c4485477 100644 --- a/packages/editor/src/browser/doc-model/editor-document-model.ts +++ b/packages/editor/src/browser/doc-model/editor-document-model.ts @@ -335,6 +335,13 @@ export class EditorDocumentModel extends Disposable implements IEditorDocumentMo if (this.monacoModel.isDisposed()) { return false; } + /** + * https://github.com/microsoft/vscode/blob/1.95.3/src/vscode-dts/vscode.d.ts#L14007 + * 如果文档是只读状态,说明并不能进行保存, 自然不需要 dirty 状态 + */ + if (this.readonly) { + return false; + } return this._persistVersionId !== this.monacoModel.getAlternativeVersionId(); } diff --git a/packages/extension/src/hosted/api/vscode/doc/doc-manager.host.ts b/packages/extension/src/hosted/api/vscode/doc/doc-manager.host.ts index ca00270a96..21e9b28c8e 100644 --- a/packages/extension/src/hosted/api/vscode/doc/doc-manager.host.ts +++ b/packages/extension/src/hosted/api/vscode/doc/doc-manager.host.ts @@ -179,15 +179,15 @@ export class ExtensionDocumentDataManagerImpl implements ExtensionDocumentDataMa $fireModelOptionsChangedEvent(e: IExtensionDocumentModelOptionsChangedEvent) { const document = this._documents.get(e.uri); if (document) { + if (isDefined(e.dirty)) { + document._acceptIsDirty(e.dirty); + } // 和 vscode 表现保持一致,接收到 languages 变更时,发送一个 close 和一个 open 事件 if (isDefined(e.languageId) && e.languageId !== document._getLanguageId()) { document._acceptLanguageId(e.languageId); this._onDidCloseTextDocument.fire(document.document); this._onDidOpenTextDocument.fire(document.document); } - if (isDefined(e.dirty)) { - document._acceptIsDirty(e.dirty); - } } } @@ -197,6 +197,7 @@ export class ExtensionDocumentDataManagerImpl implements ExtensionDocumentDataMa if (!document) { return; } + document._acceptIsDirty(dirty); document.onEvents({ eol, versionId, @@ -204,7 +205,6 @@ export class ExtensionDocumentDataManagerImpl implements ExtensionDocumentDataMa isRedoing, isUndoing, }); - document._acceptIsDirty(dirty); let reason: vscode.TextDocumentChangeReason | undefined; diff --git a/packages/monaco/src/browser/contrib/merge-editor/view/merge-editor.module.less b/packages/monaco/src/browser/contrib/merge-editor/view/merge-editor.module.less index b6bc2b83a3..ba169a6ca5 100644 --- a/packages/monaco/src/browser/contrib/merge-editor/view/merge-editor.module.less +++ b/packages/monaco/src/browser/contrib/merge-editor/view/merge-editor.module.less @@ -321,7 +321,7 @@ display: flex; align-content: center; height: inherit; - max-width: calc(100% - 120px); + max-width: calc(100% - 140px); display: flex; .title {