Skip to content

Commit

Permalink
Fix/navigation commands (#1895)
Browse files Browse the repository at this point in the history
  • Loading branch information
karan0046 authored Sep 29, 2024
1 parent 1255659 commit b4f7091
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CodeEdit/Features/WindowCommands/NavigateCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import SwiftUI

struct NavigateCommands: Commands {

@FocusedObject var editor: Editor?
@UpdatingWindowController var windowController: CodeEditWindowController?
private var editor: Editor? {
windowController?.workspace?.editorManager?.activeEditor
}

var body: some Commands {
CommandMenu("Navigate") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -51,6 +52,8 @@ struct UpdatingWindowController: DynamicProperty {
objectWillChangeCancellable = nil
utilityAreaCancellable?.cancel()
utilityAreaCancellable = nil
activeEditorCancellable?.cancel()
activeEditorCancellable = nil

self.controller = controller

Expand All @@ -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()
}
}
Expand Down

0 comments on commit b4f7091

Please sign in to comment.