diff --git a/CodeEdit/Features/CodeFile/CodeFileView.swift b/CodeEdit/Features/CodeFile/CodeFileView.swift index 594a28f49..c511fd38b 100644 --- a/CodeEdit/Features/CodeFile/CodeFileView.swift +++ b/CodeEdit/Features/CodeFile/CodeFileView.swift @@ -74,6 +74,7 @@ struct CodeFileView: View { scheduler: DispatchQueue.main ) .sink { _ in + codeFile.updateChangeCount(.changeDone) codeFile.autosave(withImplicitCancellability: false) { _ in } } diff --git a/CodeEdit/Features/Editor/Models/Editor.swift b/CodeEdit/Features/Editor/Models/Editor.swift index 788529762..2a494baa1 100644 --- a/CodeEdit/Features/Editor/Models/Editor.swift +++ b/CodeEdit/Features/Editor/Models/Editor.swift @@ -107,11 +107,6 @@ final class Editor: ObservableObject, Identifiable { if temporaryTab?.file == file { temporaryTab = nil - } else { - // When tab actually closed (not changed from temporary to normal) - // we need to set fileDocument to nil, otherwise it will keep file in memory - // and not reload content on next openTabFile with same id - file.fileDocument = nil } historyOffset = 0 @@ -122,6 +117,10 @@ final class Editor: ObservableObject, Identifiable { if let selectedTab { history.prepend(selectedTab) } + // Reset change count to 0 + file.fileDocument?.updateChangeCount(.changeCleared) + // remove file from memory + file.fileDocument = nil } /// Closes the currently opened tab in the tab group.