From 815a349e6933ea68ea857690b3d4ca596a24a4ba Mon Sep 17 00:00:00 2001 From: igor Date: Fri, 16 Jan 2026 21:15:21 -0800 Subject: [PATCH] Settings window now allows selecting path for new list item. --- src/PathManager.swift | 2 +- src/SettingsViewController.swift | 26 ++++++-------------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/src/PathManager.swift b/src/PathManager.swift index 44ba077..d04ac85 100644 --- a/src/PathManager.swift +++ b/src/PathManager.swift @@ -19,7 +19,7 @@ final class PathManager { "/Applications", "/System/Applications", "/System/Applications/Utilities", - "/System/Library/CoreServices", // TODO: NOTE: Remove this one? + "/System/Library/CoreServices", // TODO: NOTE: Remove this one? This one contains Finder and Siri. "/System/Library/CoreServices/Applications", "/Applications/Xcode.app/Contents/Applications" ] diff --git a/src/SettingsViewController.swift b/src/SettingsViewController.swift index 6476597..dc61580 100644 --- a/src/SettingsViewController.swift +++ b/src/SettingsViewController.swift @@ -468,7 +468,7 @@ class SettingsViewController: NSViewController, @objc private func reset() { - keyCode = Int(kVK_Space) + keyCode = Int(kVK_Space) // TODO: Put into something like Defaults.swift file. modifiers = Int(optionKey) HotKeyManager.shared.registerHotKey(key: keyCode, modifiers: modifiers) @@ -630,31 +630,16 @@ class SettingsViewController: NSViewController, dirPicker!.allowsMultipleSelection = false } - // WARN: - // FIX: There is a bug where the program crashes when adding a new - // path. This happens because the settings popup is closed before - // displaying the selection modal, as a result the new path item - // is cleared (well, b/c it's empty) and the path gets set into - // non-existent memory which results in segmentation fault. - - NSRunningApplication.current.activate(options: .activateAllWindows) - delegate.window.level = .normal - delegate.aboutWindow.performClose(nil) - if dirPicker!.runModal() == .OK { if let url = dirPicker!.url { + print("tag=\(tag) url.path=\(url.path)") + (pathsTableView + .view(atColumn: 0, row: tag, makeIfNecessary: false + ) as? PathsTableCellView)?.titleField.stringValue = url.path paths[tag] = url.path pathsTableView.reloadData() } } - - delegate.window.level = .statusBar - delegate.window.makeKeyAndOrderFront(nil) - if let controller = - delegate.window.contentViewController as? SearchViewController - { - controller.openSettings() - } } func numberOfRows(in tableView: NSTableView) -> Int { @@ -666,6 +651,7 @@ class SettingsViewController: NSViewController, { let rect = NSRect(x: 0, y: 0, width: tableColumn!.width, height: 20) let cell = PathsTableCellView(frame: rect) + cell.titleField.textColor = isDirectory(paths[row]) ? NSColor.labelColor : NSColor.systemRed cell.titleField.stringValue = paths[row] cell.delegate = self cell.id = row