Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 3-way git dirty status #4220

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading