Skip to content

Commit

Permalink
fix: 3-way git dirty status (#4220)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricbet authored Dec 16, 2024
1 parent ec675f6 commit eb3dfcb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand All @@ -197,14 +197,14 @@ export class ExtensionDocumentDataManagerImpl implements ExtensionDocumentDataMa
if (!document) {
return;
}
document._acceptIsDirty(dirty);
document.onEvents({
eol,
versionId,
changes,
isRedoing,
isUndoing,
});
document._acceptIsDirty(dirty);

let reason: vscode.TextDocumentChangeReason | undefined;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
display: flex;
align-content: center;
height: inherit;
max-width: calc(100% - 120px);
max-width: calc(100% - 140px);
display: flex;

.title {
Expand Down

0 comments on commit eb3dfcb

Please sign in to comment.