Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/navigation commands #1895

Merged
merged 2 commits into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading