Skip to content
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: 5 additions & 0 deletions MarkdownViewer/App/MarkdownViewerApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ struct MarkdownViewerApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@StateObject private var recentFilesStore = RecentFilesStore.shared
@ObservedObject private var editorSettings = ExternalEditorSettings.shared
@AppStorage("autoRaiseOnFileChange") private var autoRaiseOnFileChange = false

var body: some Scene {
WindowGroup {
Expand Down Expand Up @@ -102,6 +103,10 @@ struct MarkdownViewerApp: App {
appDelegate.resetZoom()
}
.keyboardShortcut("0", modifiers: .command)

Divider()

Toggle("Bring to Front on File Change", isOn: $autoRaiseOnFileChange)
}
}
Settings {
Expand Down
4 changes: 4 additions & 0 deletions MarkdownViewer/ViewModels/DocumentState.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AppKit
import Combine
import CoreGraphics
import Foundation
Expand Down Expand Up @@ -138,6 +139,9 @@ class DocumentState: ObservableObject {
self.lastModificationDate = newModDate
self.reload()
withAnimation(.easeInOut(duration: 0.2)) { self.fileChanged = true }
if UserDefaults.standard.bool(forKey: "autoRaiseOnFileChange") {
NSApplication.shared.activate(ignoringOtherApps: true)
}
}
}

Expand Down