mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 05:06:24 +03:00
terminal: dcs state cleanup in deinit
This commit is contained in:
@ -137,7 +137,11 @@ pub const Handler = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn unhook(self: *Handler) ?Command {
|
pub fn unhook(self: *Handler) ?Command {
|
||||||
|
// Note: we do NOT call deinit here on purpose because some commands
|
||||||
|
// transfer memory ownership. If state needs cleanup, the switch
|
||||||
|
// prong below should handle it.
|
||||||
defer self.state = .{ .inactive = {} };
|
defer self.state = .{ .inactive = {} };
|
||||||
|
|
||||||
return switch (self.state) {
|
return switch (self.state) {
|
||||||
.inactive,
|
.inactive,
|
||||||
.ignore,
|
.ignore,
|
||||||
@ -168,18 +172,7 @@ pub const Handler = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn discard(self: *Handler) void {
|
fn discard(self: *Handler) void {
|
||||||
switch (self.state) {
|
self.state.deinit();
|
||||||
.inactive,
|
|
||||||
.ignore,
|
|
||||||
=> {},
|
|
||||||
|
|
||||||
.xtgettcap => |*list| list.deinit(),
|
|
||||||
|
|
||||||
.decrqss => {},
|
|
||||||
|
|
||||||
.tmux => {},
|
|
||||||
}
|
|
||||||
|
|
||||||
self.state = .{ .inactive = {} };
|
self.state = .{ .inactive = {} };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -259,6 +252,18 @@ const State = union(enum) {
|
|||||||
|
|
||||||
/// Tmux control mode: https://github.com/tmux/tmux/wiki/Control-Mode
|
/// Tmux control mode: https://github.com/tmux/tmux/wiki/Control-Mode
|
||||||
tmux: void,
|
tmux: void,
|
||||||
|
|
||||||
|
pub fn deinit(self: State) void {
|
||||||
|
switch (self) {
|
||||||
|
.inactive,
|
||||||
|
.ignore,
|
||||||
|
=> {},
|
||||||
|
|
||||||
|
.xtgettcap => |*v| v.deinit(),
|
||||||
|
.decrqss => {},
|
||||||
|
.tmux => {},
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
test "unknown DCS command" {
|
test "unknown DCS command" {
|
||||||
|
Reference in New Issue
Block a user