Skip to content

Commit 9b7a26e

Browse files
committed
Share CodeFileDocument Undo Stack
1 parent 3f15efb commit 9b7a26e

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

CodeEdit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CodeEdit/Features/Editor/Views/CodeFileView.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct CodeFileView: View {
6666

6767
private let isEditable: Bool
6868

69-
private let undoManager = CEUndoManager()
69+
private let undoManager: CEUndoManager
7070

7171
init(
7272
editorInstance: EditorInstance,
@@ -88,6 +88,15 @@ struct CodeFileView: View {
8888
editorInstance.cursorPositions = openOptions.cursorPositions
8989
}
9090

91+
// Share the undo manager for the document between editors
92+
if let undoManager = codeFile.undoManager as? CEUndoManager {
93+
self.undoManager = undoManager
94+
} else {
95+
let undoManager = CEUndoManager()
96+
codeFile.undoManager = undoManager
97+
self.undoManager = undoManager
98+
}
99+
91100
updateHighlightProviders()
92101

93102
codeFile
@@ -97,8 +106,6 @@ struct CodeFileView: View {
97106
codeFile.updateChangeCount(.changeDone)
98107
}
99108
.store(in: &cancellables)
100-
101-
codeFile.undoManager = self.undoManager.manager
102109
}
103110

104111
private var currentTheme: Theme {

0 commit comments

Comments
 (0)