File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Sources/CodeEditSourceEditor Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -256,6 +256,16 @@ public class TextViewController: NSViewController {
256256 minimapView. layout ( )
257257 }
258258
259+ override public func viewDidAppear( ) {
260+ super. viewDidAppear ( )
261+ textCoordinators. forEach { $0. val? . controllerDidAppear ( controller: self ) }
262+ }
263+
264+ override public func viewDidDisappear( ) {
265+ super. viewDidDisappear ( )
266+ textCoordinators. forEach { $0. val? . controllerDidDisappear ( controller: self ) }
267+ }
268+
259269 deinit {
260270 if let highlighter {
261271 textView. removeStorageDelegate ( highlighter)
Original file line number Diff line number Diff line change @@ -26,6 +26,14 @@ public protocol TextViewCoordinator: AnyObject {
2626 /// dereferenced when ``TextViewCoordinator/destroy()-9nzfl`` is called.
2727 func prepareCoordinator( controller: TextViewController )
2828
29+ /// Called when the controller's `viewDidAppear` method is called by AppKit.
30+ /// - Parameter controller: The text view controller that did appear.
31+ func controllerDidAppear( controller: TextViewController )
32+
33+ /// Called when the controller's `viewDidDisappear` method is called by AppKit.
34+ /// - Parameter controller: The text view controller that did disappear.
35+ func controllerDidDisappear( controller: TextViewController )
36+
2937 /// Called when the text view's text changed.
3038 /// - Parameter controller: The text controller.
3139 func textViewDidChangeText( controller: TextViewController )
@@ -40,6 +48,8 @@ public protocol TextViewCoordinator: AnyObject {
4048
4149/// Default implementations
4250public extension TextViewCoordinator {
51+ func controllerDidAppear( controller: TextViewController ) { }
52+ func controllerDidDisappear( controller: TextViewController ) { }
4353 func textViewDidChangeText( controller: TextViewController ) { }
4454 func textViewDidChangeSelection( controller: TextViewController , newPositions: [ CursorPosition ] ) { }
4555 func destroy( ) { }
You can’t perform that action at this time.
0 commit comments