1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-11-09 21:20:07 +01:00

Ensure editor binaries exist or notify user (#67)

This commit is contained in:
2021-12-09 19:39:58 +01:00
parent ca2ca9df3b
commit 7feb13856d
4 changed files with 98 additions and 29 deletions

View File

@@ -23,7 +23,7 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
var sites: [Valet.Site] = []
/// Array that contains various editors that might open a particular site directory.
var editors: [Editor] = Editor.detect()
var editors: [Editor] = Editor.detectPresetEditors()
/// String that was last searched for. Empty by default.
var lastSearchedFor = ""
@@ -303,7 +303,25 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
}
@objc func openWithEditor(sender: EditorMenuItem) {
sender.editor?.openDirectory(file: selectedSite!.absolutePath!)
guard let editor = sender.editor else { return }
if editor.hasBinary() {
editor.openDirectory(file: selectedSite!.absolutePath!)
} else {
Alert.confirm(
onWindow: self.view.window!,
messageText: "editors.binary_missing.title"
.localized(
editor.pathToBinary
),
informativeText: editor.missingBinaryInstruction ?? "",
buttonTitle: "editors.alert.try_again".localized,
secondButtonTitle: "editors.alert.cancel".localized,
onFirstButtonPressed: {
self.openWithEditor(sender: sender)
}
)
}
}
// MARK: - Deinitialization