Harden cmux theme override writes

This commit is contained in:
Lawrence Chen 2026-03-13 07:00:05 -07:00
parent 6d955a6f40
commit e1f6d24655
No known key found for this signature in database
2 changed files with 4 additions and 3 deletions

View file

@ -5996,10 +5996,11 @@ struct CMUXCLI {
private func removingManagedThemeOverride(from contents: String) -> String {
let pattern = #"(?ms)\n?# cmux themes start\n.*?\n# cmux themes end\n?"#
guard let range = contents.range(of: pattern, options: [.regularExpression]) else {
guard let regex = try? NSRegularExpression(pattern: pattern) else {
return contents
}
return contents.replacingCharacters(in: range, with: "")
let fullRange = NSRange(contents.startIndex..<contents.endIndex, in: contents)
return regex.stringByReplacingMatches(in: contents, options: [], range: fullRange, withTemplate: "")
}
private func reloadThemesIfPossible() -> ThemeReloadStatus {