From 23202990df97dbcd22e4f6274bdf1f21b0915b13 Mon Sep 17 00:00:00 2001 From: atani Date: Sat, 7 Mar 2026 01:08:51 +0900 Subject: [PATCH] fix: scan app-support config paths for existing font-codepoint-map Include ~/Library/Application Support//config(.ghostty) paths in the codepoint-map detection scan. This ensures that font-codepoint-map entries in the release app-support config (loaded by loadReleaseAppSupportGhosttyConfigIfNeeded for debug builds) are detected before injecting CJK font fallback defaults. --- Sources/GhosttyTerminalView.swift | 37 +++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/Sources/GhosttyTerminalView.swift b/Sources/GhosttyTerminalView.swift index 4d608fa0..42c2fbeb 100644 --- a/Sources/GhosttyTerminalView.swift +++ b/Sources/GhosttyTerminalView.swift @@ -1100,14 +1100,10 @@ class GhosttyApp { } /// Checks whether the user's Ghostty config files already contain - /// a `font-codepoint-map` entry covering CJK ranges. + /// a `font-codepoint-map` entry covering CJK ranges. Also checks + /// application-support config paths that cmux may load at runtime. static func userConfigContainsCJKCodepointMap( - configPaths: [String] = [ - "~/.config/ghostty/config", - "~/.config/ghostty/config.ghostty", - "~/Library/Application Support/com.mitchellh.ghostty/config", - "~/Library/Application Support/com.mitchellh.ghostty/config.ghostty", - ] + configPaths: [String] = defaultCJKScanPaths() ) -> Bool { var visited = Set() for rawPath in configPaths { @@ -1119,6 +1115,33 @@ class GhosttyApp { return false } + /// Returns the default set of config paths to scan for existing + /// `font-codepoint-map` entries. Includes both the standard Ghostty + /// config locations and any app-support paths that cmux may load. + private static func defaultCJKScanPaths() -> [String] { + var paths = [ + "~/.config/ghostty/config", + "~/.config/ghostty/config.ghostty", + "~/Library/Application Support/com.mitchellh.ghostty/config", + "~/Library/Application Support/com.mitchellh.ghostty/config.ghostty", + ] + if let appSupport = FileManager.default.urls( + for: .applicationSupportDirectory, + in: .userDomainMask + ).first { + let releaseDir = appSupport.appendingPathComponent(releaseBundleIdentifier) + paths.append(releaseDir.appendingPathComponent("config").path) + paths.append(releaseDir.appendingPathComponent("config.ghostty").path) + + if let bundleId = Bundle.main.bundleIdentifier, bundleId != releaseBundleIdentifier { + let currentDir = appSupport.appendingPathComponent(bundleId) + paths.append(currentDir.appendingPathComponent("config").path) + paths.append(currentDir.appendingPathComponent("config.ghostty").path) + } + } + return paths + } + /// Scans a single config file (and any files it includes) for /// `font-codepoint-map` entries. Tracks visited paths to prevent /// infinite recursion on cyclic includes.