From 0c83c3a773e80d01b6a2b88c742989968e306bab Mon Sep 17 00:00:00 2001 From: Karan Sah Date: Sat, 28 Sep 2024 21:50:49 +0530 Subject: [PATCH] Observer added to reflect instant changes on UI --- .../Utils/WindowControllerPropertyWrapper.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CodeEdit/Features/WindowCommands/Utils/WindowControllerPropertyWrapper.swift b/CodeEdit/Features/WindowCommands/Utils/WindowControllerPropertyWrapper.swift index f5130a034..6b7311afa 100644 --- a/CodeEdit/Features/WindowCommands/Utils/WindowControllerPropertyWrapper.swift +++ b/CodeEdit/Features/WindowCommands/Utils/WindowControllerPropertyWrapper.swift @@ -39,6 +39,7 @@ struct UpdatingWindowController: DynamicProperty { private var objectWillChangeCancellable: AnyCancellable? private var utilityAreaCancellable: AnyCancellable? // ``ViewCommands`` needs this. private var windowCancellable: AnyCancellable? + private var activeEditorCancellable: AnyCancellable? init() { windowCancellable = NSApp.publisher(for: \.keyWindow).sink { [weak self] window in @@ -51,6 +52,8 @@ struct UpdatingWindowController: DynamicProperty { objectWillChangeCancellable = nil utilityAreaCancellable?.cancel() utilityAreaCancellable = nil + activeEditorCancellable?.cancel() + activeEditorCancellable = nil self.controller = controller @@ -60,6 +63,10 @@ struct UpdatingWindowController: DynamicProperty { utilityAreaCancellable = controller?.workspace?.utilityAreaModel?.objectWillChange.sink { [weak self] in self?.objectWillChange.send() } + let activeEditor = controller?.workspace?.editorManager?.activeEditor + activeEditorCancellable = activeEditor?.objectWillChange.sink { [weak self] in + self?.objectWillChange.send() + } self.objectWillChange.send() } }