diff --git a/EditorExtension/Application/Source/AppDelegate.swift b/EditorExtension/Application/Source/AppDelegate.swift index e80477ea..cd623198 100644 --- a/EditorExtension/Application/Source/AppDelegate.swift +++ b/EditorExtension/Application/Source/AppDelegate.swift @@ -52,8 +52,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { let dialog = NSOpenPanel() dialog.title = "Choose a configuration file" + dialog.delegate = self + dialog.showsHiddenFiles = true dialog.showsResizeIndicator = true - dialog.allowedFileTypes = [URL(fileURLWithPath: swiftFormatConfigurationFile).pathExtension] dialog.allowsMultipleSelection = false dialog.beginSheetModal(for: window) { response in @@ -101,6 +102,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { let dialog = NSSavePanel() dialog.title = "Export Configuration" + dialog.showsHiddenFiles = true dialog.nameFieldStringValue = swiftFormatConfigurationFile dialog.beginSheetModal(for: window) { response in guard response == .OK, let url = dialog.url else { @@ -131,6 +133,14 @@ class AppDelegate: NSObject, NSApplicationDelegate { } } +extension AppDelegate: NSOpenSavePanelDelegate { + func panel(_: Any, shouldEnable url: URL) -> Bool { + return url.hasDirectoryPath || + url.pathExtension == swiftFormatConfigurationFile.dropFirst() || + url.lastPathComponent == swiftFormatConfigurationFile + } +} + extension NSNotification.Name { static let applicationDidLoadNewConfiguration = NSNotification.Name("ApplicationDidLoadNewConfiguration") }