mirror of
https://github.com/lune-org/lune.git
synced 2025-04-10 21:40:54 +01:00
Fix table indentation and newline issues with new value formatter
This commit is contained in:
parent
395c36fa8b
commit
bfb89dec01
1 changed files with 10 additions and 1 deletions
|
@ -52,6 +52,7 @@ pub(crate) fn format_value_recursive(
|
||||||
} else {
|
} else {
|
||||||
writeln!(buffer, "{}", STYLE_DIM.apply_to("{"))?;
|
writeln!(buffer, "{}", STYLE_DIM.apply_to("{"))?;
|
||||||
|
|
||||||
|
let mut is_empty = true;
|
||||||
for res in t.clone().pairs::<LuaValue, LuaValue>() {
|
for res in t.clone().pairs::<LuaValue, LuaValue>() {
|
||||||
let (key, value) = res.expect("conversion to LuaValue should never fail");
|
let (key, value) = res.expect("conversion to LuaValue should never fail");
|
||||||
let formatted = if let Some(plain_key) = lua_value_as_plain_string_key(&key) {
|
let formatted = if let Some(plain_key) = lua_value_as_plain_string_key(&key) {
|
||||||
|
@ -75,10 +76,18 @@ pub(crate) fn format_value_recursive(
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
buffer.push_str(&formatted);
|
buffer.push_str(&formatted);
|
||||||
|
buffer.push('\n');
|
||||||
|
is_empty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
visited.remove(&LuaValueId::from(t));
|
visited.remove(&LuaValueId::from(t));
|
||||||
write!(buffer, "\n{}", STYLE_DIM.apply_to("}"))?;
|
write!(
|
||||||
|
buffer,
|
||||||
|
"{}{}{}",
|
||||||
|
INDENT.repeat(depth),
|
||||||
|
if is_empty { " " } else { "" },
|
||||||
|
STYLE_DIM.apply_to("}")
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let prefer_plain = depth == 0;
|
let prefer_plain = depth == 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue