bread-theme: validate surfaces.*.anchor like its width/layer siblings
anchor was the one enum-shaped schema field taken via unwrap_or_default() with no manifest-time validation, while width and layer both bail! on an unrecognized value (as does bar.window.anchors). A typo'd anchor silently fell through to breadbar's own runtime eprintln + unanchored-window fallback instead of the load-time hard error every other typo'd key gets. Validate against the three shapes breadbar/src/surface.rs actually implements.
This commit is contained in:
parent
470d2aa7e9
commit
a313eb518c
3 changed files with 81 additions and 1 deletions
|
|
@ -414,6 +414,18 @@ fn resolve_surfaces(
|
|||
let mut out = BTreeMap::new();
|
||||
let Some(raw) = raw else { return Ok(out) };
|
||||
for (namespace, s) in raw {
|
||||
let anchor = match s.anchor.as_deref() {
|
||||
Some(a @ ("top_right" | "bottom_centre" | "fill")) => a.to_string(),
|
||||
Some(other) => bail!(
|
||||
"theme '{theme_id}': surfaces.{namespace}.anchor = \"{other}\" is not \
|
||||
top_right|bottom_centre|fill (the only shapes breadbar's satellite \
|
||||
windows implement — see breadbar/src/surface.rs)"
|
||||
),
|
||||
None => bail!(
|
||||
"theme '{theme_id}': surfaces.{namespace} has no anchor set \
|
||||
(expected one of top_right|bottom_centre|fill)"
|
||||
),
|
||||
};
|
||||
let offset = match &s.offset {
|
||||
None => vec![],
|
||||
Some(RawOffset::Single(v)) => vec![*v],
|
||||
|
|
@ -439,7 +451,7 @@ fn resolve_surfaces(
|
|||
out.insert(
|
||||
namespace.clone(),
|
||||
Surface {
|
||||
anchor: s.anchor.clone().unwrap_or_default(),
|
||||
anchor,
|
||||
offset,
|
||||
width,
|
||||
layer,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue