Skip to content

Commit 1a6e32c

Browse files
Ensure Coordinator's Lifetime is Equal To The Editor's (#340)
### Description Guarantees that all text coordinator's lifetimes match that of the editor's. ### Related Issues * CodeEditApp/CodeEdit#2058 ### Checklist - [x] I read and understood the [contributing guide](https://github.com/CodeEditApp/CodeEdit/blob/main/CONTRIBUTING.md) as well as the [code of conduct](https://github.com/CodeEditApp/CodeEdit/blob/main/CODE_OF_CONDUCT.md) - [x] The issues this PR addresses are related to each other - [x] My changes generate no new warnings - [x] My code builds and runs on my machine - [x] My changes are all related to the related issue above - [x] I documented my code ### Screenshots
1 parent fd1fafe commit 1a6e32c

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

Sources/CodeEditSourceEditor/Controller/TextViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ public class TextViewController: NSViewController {
234234
coordinators.forEach {
235235
$0.prepareCoordinator(controller: self)
236236
}
237+
self.textCoordinators = coordinators.map { WeakCoordinator($0) }
237238
}
238239

239240
required init?(coder: NSCoder) {

Sources/CodeEditSourceEditor/SourceEditor/SourceEditor.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,6 @@ public struct SourceEditor: NSViewControllerRepresentable {
128128
context.coordinator.isUpdatingFromRepresentable = false
129129
}
130130

131-
// Set this no matter what to avoid having to compare object pointers.
132-
controller.textCoordinators = coordinators.map { WeakCoordinator($0) }
133-
134131
// Do manual diffing to reduce the amount of reloads.
135132
// This helps a lot in view performance, as it otherwise gets triggered on each environment change.
136133
guard !paramsAreEqual(controller: controller, coordinator: context.coordinator) else {

0 commit comments

Comments
 (0)