Fix ARC workspace inheritance crash and native Zig helper builds (#2283)
* Fix ARC workspace inheritance crash and native Zig helper builds * Fix Nightly Cmd+N workspace creation crash * Restore safe terminal config snapshots for Intel Nightly
This commit is contained in:
parent
f0c3ccc314
commit
c4bc18d906
6 changed files with 265 additions and 213 deletions
|
|
@ -2973,7 +2973,7 @@ final class TerminalSurface: Identifiable, ObservableObject {
|
|||
return val > 0 ? val : 10
|
||||
}()
|
||||
private let surfaceContext: ghostty_surface_context_e
|
||||
private let configTemplate: ghostty_surface_config_s?
|
||||
private let configTemplate: CmuxSurfaceConfigTemplate?
|
||||
private let workingDirectory: String?
|
||||
private let initialCommand: String?
|
||||
private let initialEnvironmentOverrides: [String: String]
|
||||
|
|
@ -3061,7 +3061,7 @@ final class TerminalSurface: Identifiable, ObservableObject {
|
|||
init(
|
||||
tabId: UUID,
|
||||
context: ghostty_surface_context_e,
|
||||
configTemplate: ghostty_surface_config_s?,
|
||||
configTemplate: CmuxSurfaceConfigTemplate?,
|
||||
workingDirectory: String? = nil,
|
||||
initialCommand: String? = nil,
|
||||
initialEnvironmentOverrides: [String: String] = [:],
|
||||
|
|
@ -3585,7 +3585,10 @@ final class TerminalSurface: Identifiable, ObservableObject {
|
|||
|
||||
let scaleFactors = scaleFactors(for: view)
|
||||
|
||||
var surfaceConfig = configTemplate ?? ghostty_surface_config_new()
|
||||
let baseConfig = configTemplate ?? CmuxSurfaceConfigTemplate()
|
||||
var surfaceConfig = ghostty_surface_config_new()
|
||||
surfaceConfig.font_size = baseConfig.fontSize
|
||||
surfaceConfig.wait_after_command = baseConfig.waitAfterCommand
|
||||
surfaceConfig.platform_tag = GHOSTTY_PLATFORM_MACOS
|
||||
surfaceConfig.platform = ghostty_platform_u(macos: ghostty_platform_macos_s(
|
||||
nsview: Unmanaged.passUnretained(view).toOpaque()
|
||||
|
|
@ -3612,19 +3615,7 @@ final class TerminalSurface: Identifiable, ObservableObject {
|
|||
}
|
||||
}
|
||||
|
||||
var env: [String: String] = [:]
|
||||
if surfaceConfig.env_var_count > 0, let existingEnv = surfaceConfig.env_vars {
|
||||
let count = Int(surfaceConfig.env_var_count)
|
||||
if count > 0 {
|
||||
for i in 0..<count {
|
||||
let item = existingEnv[i]
|
||||
if let key = String(cString: item.key, encoding: .utf8),
|
||||
let value = String(cString: item.value, encoding: .utf8) {
|
||||
env[key] = value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var env = baseConfig.environmentVariables
|
||||
|
||||
var protectedStartupEnvironmentKeys: Set<String> = []
|
||||
func setManagedEnvironmentValue(_ key: String, _ value: String) {
|
||||
|
|
@ -3762,26 +3753,36 @@ final class TerminalSurface: Identifiable, ObservableObject {
|
|||
}
|
||||
}
|
||||
|
||||
let createWithCommandAndWorkingDirectory = { [self] in
|
||||
let resolvedWorkingDirectory: String? = {
|
||||
if let workingDirectory, !workingDirectory.isEmpty {
|
||||
return workingDirectory
|
||||
}
|
||||
return baseConfig.workingDirectory
|
||||
}()
|
||||
let resolvedCommand: String? = {
|
||||
if let initialCommand, !initialCommand.isEmpty {
|
||||
initialCommand.withCString { cCommand in
|
||||
surfaceConfig.command = cCommand
|
||||
if let workingDirectory, !workingDirectory.isEmpty {
|
||||
workingDirectory.withCString { cWorkingDir in
|
||||
surfaceConfig.working_directory = cWorkingDir
|
||||
createSurface()
|
||||
}
|
||||
} else {
|
||||
return initialCommand
|
||||
}
|
||||
return baseConfig.command
|
||||
}()
|
||||
let resolvedInitialInput = baseConfig.initialInput
|
||||
func withOptionalCString<T>(_ value: String?, _ body: (UnsafePointer<CChar>?) -> T) -> T {
|
||||
guard let value else {
|
||||
return body(nil)
|
||||
}
|
||||
return value.withCString(body)
|
||||
}
|
||||
|
||||
let createWithCommandAndWorkingDirectory = {
|
||||
withOptionalCString(resolvedCommand) { cCommand in
|
||||
surfaceConfig.command = cCommand
|
||||
withOptionalCString(resolvedWorkingDirectory) { cWorkingDir in
|
||||
surfaceConfig.working_directory = cWorkingDir
|
||||
withOptionalCString(resolvedInitialInput) { cInitialInput in
|
||||
surfaceConfig.initial_input = cInitialInput
|
||||
createSurface()
|
||||
}
|
||||
}
|
||||
} else if let workingDirectory, !workingDirectory.isEmpty {
|
||||
workingDirectory.withCString { cWorkingDir in
|
||||
surfaceConfig.working_directory = cWorkingDir
|
||||
createSurface()
|
||||
}
|
||||
} else {
|
||||
createSurface()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3844,7 +3845,7 @@ final class TerminalSurface: Identifiable, ObservableObject {
|
|||
// config/scale reconciliation. If runtime points don't match the inherited
|
||||
// template points, re-apply via binding action so all creation paths
|
||||
// (new surface, split, new workspace) preserve zoom from the source terminal.
|
||||
if let inheritedFontPoints = configTemplate?.font_size,
|
||||
if let inheritedFontPoints = configTemplate?.fontSize,
|
||||
inheritedFontPoints > 0 {
|
||||
let currentFontPoints = cmuxCurrentSurfaceFontSizePoints(createdSurface)
|
||||
let shouldReapply = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue