mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
config: clone() should run the replay steps
This preserves replay steps for future use. Previously, clone copied values but failed to copy the replay steps.
This commit is contained in:
@ -2981,31 +2981,25 @@ pub fn shallowClone(self: *const Config, alloc_gpa: Allocator) Config {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a copy of this configuration. This is useful as a starting
|
/// Create a copy of this configuration.
|
||||||
/// point for modifying a configuration since a config can NOT be
|
///
|
||||||
/// modified once it is in use by an app or surface.
|
/// This will not re-read referenced configuration files except for the
|
||||||
|
/// theme, but the config-file values will be preserved.
|
||||||
pub fn clone(
|
pub fn clone(
|
||||||
self: *const Config,
|
self: *const Config,
|
||||||
alloc_gpa: Allocator,
|
alloc_gpa: Allocator,
|
||||||
) Allocator.Error!Config {
|
) !Config {
|
||||||
// Start with an empty config with a new arena we're going
|
// Create a new config with a new arena
|
||||||
// to use for all our copies.
|
var new_config = try default(alloc_gpa);
|
||||||
var result: Config = .{
|
errdefer new_config.deinit();
|
||||||
._arena = ArenaAllocator.init(alloc_gpa),
|
new_config._conditional_state = self._conditional_state;
|
||||||
};
|
|
||||||
errdefer result.deinit();
|
|
||||||
const alloc = result._arena.?.allocator();
|
|
||||||
|
|
||||||
inline for (@typeInfo(Config).Struct.fields) |field| {
|
// Replay all of our steps to rebuild the configuration
|
||||||
if (!@hasField(Key, field.name)) continue;
|
var it = Replay.iterator(self._replay_steps.items, &new_config);
|
||||||
@field(result, field.name) = try cloneValue(
|
try new_config.loadIter(alloc_gpa, &it);
|
||||||
alloc,
|
try new_config.finalize();
|
||||||
field.type,
|
|
||||||
@field(self, field.name),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return new_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cloneValue(
|
fn cloneValue(
|
||||||
|
Reference in New Issue
Block a user