fix(resurrection): properly serialize certain edge cases (#2907)
* fix(resurrection): properly serialize certain edge cases * style(fmt): rustfmt
This commit is contained in:
parent
3ae742d73f
commit
3bb30026f6
1 changed files with 14 additions and 8 deletions
|
|
@ -104,16 +104,17 @@ fn stringify_tab(
|
||||||
pane_contents: &mut BTreeMap<String, String>,
|
pane_contents: &mut BTreeMap<String, String>,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
let mut kdl_string = String::new();
|
let mut kdl_string = String::new();
|
||||||
// let tiled_panes_layout = get_tiled_panes_layout_from_panegeoms(tiled_panes, None);
|
|
||||||
match get_tiled_panes_layout_from_panegeoms(tiled_panes, None) {
|
match get_tiled_panes_layout_from_panegeoms(tiled_panes, None) {
|
||||||
Some(tiled_panes_layout) => {
|
Some(tiled_panes_layout) => {
|
||||||
let floating_panes_layout = get_floating_panes_layout_from_panegeoms(floating_panes);
|
let floating_panes_layout = get_floating_panes_layout_from_panegeoms(floating_panes);
|
||||||
let tiled_panes =
|
let tiled_panes = if &tiled_panes_layout.children_split_direction
|
||||||
if &tiled_panes_layout.children_split_direction != &SplitDirection::default() {
|
!= &SplitDirection::default()
|
||||||
vec![tiled_panes_layout]
|
|| tiled_panes_layout.children_are_stacked
|
||||||
} else {
|
{
|
||||||
tiled_panes_layout.children
|
vec![tiled_panes_layout]
|
||||||
};
|
} else {
|
||||||
|
tiled_panes_layout.children
|
||||||
|
};
|
||||||
let mut tab_attributes = vec![format!("name=\"{}\"", tab_name,)];
|
let mut tab_attributes = vec![format!("name=\"{}\"", tab_name,)];
|
||||||
if is_focused {
|
if is_focused {
|
||||||
tab_attributes.push(format!("focus=true"));
|
tab_attributes.push(format!("focus=true"));
|
||||||
|
|
@ -182,6 +183,7 @@ fn kdl_string_from_tiled_pane(
|
||||||
let (plugin, plugin_config) = extract_plugin_and_config(&layout.run);
|
let (plugin, plugin_config) = extract_plugin_and_config(&layout.run);
|
||||||
let (edit, _line_number) = extract_edit_and_line_number(&layout.run);
|
let (edit, _line_number) = extract_edit_and_line_number(&layout.run);
|
||||||
let cwd = layout.run.as_ref().and_then(|r| r.get_cwd());
|
let cwd = layout.run.as_ref().and_then(|r| r.get_cwd());
|
||||||
|
let has_children = layout.external_children_index.is_some() || !layout.children.is_empty();
|
||||||
let mut kdl_string = stringify_pane_title_and_attributes(
|
let mut kdl_string = stringify_pane_title_and_attributes(
|
||||||
&command,
|
&command,
|
||||||
&edit,
|
&edit,
|
||||||
|
|
@ -190,6 +192,7 @@ fn kdl_string_from_tiled_pane(
|
||||||
layout.focus,
|
layout.focus,
|
||||||
&layout.pane_initial_contents,
|
&layout.pane_initial_contents,
|
||||||
pane_contents,
|
pane_contents,
|
||||||
|
has_children,
|
||||||
);
|
);
|
||||||
|
|
||||||
stringify_tiled_layout_attributes(&layout, ignore_size, &mut kdl_string);
|
stringify_tiled_layout_attributes(&layout, ignore_size, &mut kdl_string);
|
||||||
|
|
@ -260,6 +263,7 @@ fn stringify_pane_title_and_attributes(
|
||||||
focus: Option<bool>,
|
focus: Option<bool>,
|
||||||
initial_pane_contents: &Option<String>,
|
initial_pane_contents: &Option<String>,
|
||||||
pane_contents: &mut BTreeMap<String, String>,
|
pane_contents: &mut BTreeMap<String, String>,
|
||||||
|
has_children: bool,
|
||||||
) -> String {
|
) -> String {
|
||||||
let mut kdl_string = match (&command, &edit) {
|
let mut kdl_string = match (&command, &edit) {
|
||||||
(Some(command), _) => format!("pane command=\"{}\"", command),
|
(Some(command), _) => format!("pane command=\"{}\"", command),
|
||||||
|
|
@ -271,7 +275,7 @@ fn stringify_pane_title_and_attributes(
|
||||||
}
|
}
|
||||||
if let Some(cwd) = cwd {
|
if let Some(cwd) = cwd {
|
||||||
let path = cwd.display().to_string();
|
let path = cwd.display().to_string();
|
||||||
if !path.is_empty() {
|
if !path.is_empty() && !has_children {
|
||||||
kdl_string.push_str(&format!(" cwd=\"{}\"", path));
|
kdl_string.push_str(&format!(" cwd=\"{}\"", path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -549,6 +553,7 @@ fn kdl_string_from_floating_pane(
|
||||||
let (plugin, plugin_config) = extract_plugin_and_config(&layout.run);
|
let (plugin, plugin_config) = extract_plugin_and_config(&layout.run);
|
||||||
let (edit, _line_number) = extract_edit_and_line_number(&layout.run);
|
let (edit, _line_number) = extract_edit_and_line_number(&layout.run);
|
||||||
let cwd = layout.run.as_ref().and_then(|r| r.get_cwd());
|
let cwd = layout.run.as_ref().and_then(|r| r.get_cwd());
|
||||||
|
let has_children = false;
|
||||||
let mut kdl_string = stringify_pane_title_and_attributes(
|
let mut kdl_string = stringify_pane_title_and_attributes(
|
||||||
&command,
|
&command,
|
||||||
&edit,
|
&edit,
|
||||||
|
|
@ -557,6 +562,7 @@ fn kdl_string_from_floating_pane(
|
||||||
layout.focus,
|
layout.focus,
|
||||||
&layout.pane_initial_contents,
|
&layout.pane_initial_contents,
|
||||||
pane_contents,
|
pane_contents,
|
||||||
|
has_children,
|
||||||
);
|
);
|
||||||
kdl_string.push_str(" {\n");
|
kdl_string.push_str(" {\n");
|
||||||
stringify_start_suspended(&command, &mut kdl_string);
|
stringify_start_suspended(&command, &mut kdl_string);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue