krz/orgstar

A native macOS editor for org-mode files. editor org-mode swift

Commit 0e58e1b1ae

0e58e1b1ae285390762ec1b8bf93c882ecc94a02

parent: 68b118ae7a

Verified · cmc

cmc <hello@cleberg.net> · 2026-10-08 03:40 UTC

Watch the legacy Application Support folder for config edits

A keymap.toml (or other config file) read from the folder earlier
versions used now reloads when edited there.

Layout: unified · split

Sources/OrgApp/ConfigSync.swift +7 −2
@@ -62,8 +62,11 @@ public final class ConfigSync {
6262 MainActor.assumeIsolated { self?.writeBack() }
6363 }
6464 guard watch else { return }
65 let directory = url.deletingLastPathComponent()
66 watcher = FSEventsWatcher(roots: [directory.resolvingSymlinksInPath()]) { [weak self] events in
65 let directory = url.deletingLastPathComponent().resolvingSymlinksInPath()
66 // Files still read from where earlier versions kept them reload when edited there too.
67 let legacy = UserConfig.legacyDirectory.resolvingSymlinksInPath()
68 let watchesLegacy = legacy.path != directory.path && FileManager.default.fileExists(atPath: legacy.path)
69 watcher = FSEventsWatcher(roots: [directory] + (watchesLegacy ? [legacy] : [])) { [weak self] events in
6770 let changed = Set(events.compactMap { event -> URL? in
6871 if case .changed(let url) = event { return url }
6972 return nil
@@ -71,6 +74,8 @@ public final class ConfigSync {
7174 Task { @MainActor [weak self] in
7275 guard let self else { return }
7376 for file in changed.sorted(by: { $0.path < $1.path }) {
77 if !file.path.hasPrefix(directory.path + "/"),
78 UserConfig.file(file.lastPathComponent).resolvingSymlinksInPath().path != file.resolvingSymlinksInPath().path { continue }
7479 let name = file.lastPathComponent
7580 if name == self.url.lastPathComponent { self.reload() }
7681 if self.isThemeFile(file) { self.readTheme() }
Sources/OrgApp/UserConfig.swift +6 −2
@@ -23,12 +23,16 @@ public enum UserConfig {
2323 return URL(fileURLWithPath: NSHomeDirectory()).appendingPathComponent(".config/orgstar")
2424 }
2525
26 /// Where earlier versions kept the configuration files.
27 public static var legacyDirectory: URL {
28 FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0].appendingPathComponent("Orgstar")
29 }
30
2631 /// A file of the configuration folder; one that exists only where earlier versions kept
2732 /// it (Application Support) is still read from there.
2833 public static func file(_ name: String) -> URL {
2934 let url = directory.appendingPathComponent(name)
30 let legacy = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0]
31 .appendingPathComponent("Orgstar").appendingPathComponent(name)
35 let legacy = legacyDirectory.appendingPathComponent(name)
3236 let manager = FileManager.default
3337 if !manager.fileExists(atPath: url.path), manager.fileExists(atPath: legacy.path) { return legacy }
3438 return url