redbear-power: persist show_full_cmdline in session state
The C key toggle state now survives app restart via serde-backed session.toml. Uses #[serde(default)] for backward compatibility with existing session files.
This commit is contained in:
@@ -522,6 +522,7 @@ impl App {
|
||||
app.process_tree = session.process_tree;
|
||||
app.folded = session.folded.into_iter().collect();
|
||||
app.process_filter = session.process_filter;
|
||||
app.show_full_cmdline = session.show_full_cmdline;
|
||||
app
|
||||
}
|
||||
|
||||
@@ -542,6 +543,7 @@ impl App {
|
||||
process_tree: self.process_tree,
|
||||
folded: self.folded.iter().copied().collect(),
|
||||
process_filter: self.process_filter.clone(),
|
||||
show_full_cmdline: self.show_full_cmdline,
|
||||
};
|
||||
session.save();
|
||||
}
|
||||
@@ -1875,6 +1877,7 @@ mod tests {
|
||||
process_tree: app.process_tree,
|
||||
folded: app.folded.iter().copied().collect(),
|
||||
process_filter: app.process_filter.clone(),
|
||||
show_full_cmdline: app.show_full_cmdline,
|
||||
};
|
||||
let serialized = toml::to_string(&session).unwrap();
|
||||
let parsed: crate::session::SessionState = toml::from_str(&serialized).unwrap();
|
||||
|
||||
@@ -42,6 +42,9 @@ pub struct SessionState {
|
||||
pub folded: Vec<u32>,
|
||||
/// Active filter string. Empty = no filter.
|
||||
pub process_filter: String,
|
||||
/// Show full command line instead of comm name.
|
||||
#[serde(default)]
|
||||
pub show_full_cmdline: bool,
|
||||
}
|
||||
|
||||
impl Default for SessionState {
|
||||
@@ -53,6 +56,7 @@ impl Default for SessionState {
|
||||
process_tree: false,
|
||||
folded: Vec::new(),
|
||||
process_filter: String::new(),
|
||||
show_full_cmdline: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,6 +164,7 @@ mod tests {
|
||||
process_tree: true,
|
||||
folded: vec![100, 200, 300],
|
||||
process_filter: "kworker".to_string(),
|
||||
show_full_cmdline: true,
|
||||
};
|
||||
let serialized = toml::to_string(&s).unwrap();
|
||||
let parsed: SessionState = toml::from_str(&serialized).unwrap();
|
||||
@@ -218,6 +223,7 @@ mod tests {
|
||||
process_tree: false,
|
||||
folded: vec![42],
|
||||
process_filter: "bash".to_string(),
|
||||
show_full_cmdline: false,
|
||||
};
|
||||
let serialized = toml::to_string(&s).unwrap();
|
||||
// Mimic the temp+rename flow with a different name
|
||||
|
||||
Reference in New Issue
Block a user