macOS: use default app for `*.ghostty` files first (#9180)

A small improvement for #8885, tested `config` and `config.ghostty`

<img width="526" height="267" alt="image"
src="https://github.com/user-attachments/assets/d09305ab-4a87-4393-b09c-804e618968f3"
/>
pull/9184/head
Xiangbao Meng 2025-10-13 15:52:00 +02:00 committed by GitHub
parent f5af3d4585
commit dafb9e89a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -637,8 +637,9 @@ extension Ghostty {
switch action.kind {
case .text:
// Open with the default text editor
if let textEditor = NSWorkspace.shared.defaultTextEditor {
// Open with the default editor for `*.ghostty` file or just system text editor
let editor = NSWorkspace.shared.defaultApplicationURL(forExtension: url.pathExtension) ?? NSWorkspace.shared.defaultTextEditor
if let textEditor = editor {
NSWorkspace.shared.open([url], withApplicationAt: textEditor, configuration: NSWorkspace.OpenConfiguration())
return true
}