Skip to content

Commit cc3a125

Browse files
committed
Document UndoManagerRegistration Further
1 parent 28646bd commit cc3a125

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

CodeEdit/Features/Editor/Models/Restoration/UndoManagerRegistration.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@ import CodeEditTextView
1010

1111
/// Very simple class for registering undo manager for files for a project session. This does not do any saving, it
1212
/// just stores the undo managers in memory and retrieves them as necessary for files.
13+
///
14+
/// Undo stacks aren't stored on `CEWorkspaceFile` or `CodeFileDocument` because:
15+
/// - `CEWorkspaceFile` can be refreshed and reloaded at any point.
16+
/// - `CodeFileDocument` is released once there are no editors viewing it.
17+
/// Undo stacks need to be retained for the duration of a workspace session, enduring editor closes..
1318
final class UndoManagerRegistration: ObservableObject {
1419
private var managerMap: [CEWorkspaceFile.ID: CEUndoManager] = [:]
1520

1621
init() { }
17-
22+
23+
/// Find or create a new undo manager.
24+
/// - Parameter file: The file to create for.
25+
/// - Returns: The undo manager for the given file.
1826
func manager(forFile file: CEWorkspaceFile) -> CEUndoManager {
1927
if let manager = managerMap[file.id] {
2028
return manager

0 commit comments

Comments
 (0)