mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-07 12:13:20 +00:00
docs(docking): a label left with a digit keeps its text, not only one with a letter (#410)
A blank name falls back to the default label only when no letter or
digit is left ("{name} 2" gives "2"); the docs and the rustdoc of
labels::named said a letter. A test pins both cases.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0f2ad92204
commit
9f68b84897
@@ -177,6 +177,9 @@ fn a_label_that_is_only_the_placeholder_falls_back_to_the_default() {
|
||||
assert_eq!(labels::named("{name}", labels::MOVE_GROUP, String::new), "Move tab group");
|
||||
assert_eq!(labels::named("{name}", labels::MOVE_GROUP, || "Layers".into()), "Layers");
|
||||
assert_eq!(labels::named("Move the {name} column", labels::MOVE_COLUMN, || " \t".into()), "Move the column");
|
||||
// A digit is enough to keep the label's own text.
|
||||
assert_eq!(labels::named("{name} 2", labels::MOVE_GROUP, String::new), "2");
|
||||
assert_eq!(labels::named("({name})", labels::MOVE_GROUP, String::new), "Move tab group");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -103,8 +103,8 @@ impl DockStyle {
|
||||
|
||||
/// `label` with every `{name}` replaced by `name()`, which only runs when there is one. A blank
|
||||
/// name leaves each placeholder out with what only made sense around it (see [`unnamed`]); a
|
||||
/// label with no letter left gives `fallback`, so no handle is announced with a hole in its name
|
||||
/// or without one.
|
||||
/// label with no letter or digit left gives `fallback`, so no handle is announced with a hole in
|
||||
/// its name or without one.
|
||||
pub(super) fn named(label: &str, fallback: &str, name: impl FnOnce() -> String) -> String {
|
||||
if !label.contains(NAME) {
|
||||
return label.to_owned();
|
||||
|
||||
+2
-2
@@ -747,8 +747,8 @@ what the handle moves: the logical label of the panel the group shows, or of the
|
||||
column's groups show, joined by ", " (fixed, not localized). An untitled panel is left out. With
|
||||
no title at all, the placeholder goes with the brackets or quotes around it, a separator right
|
||||
after it and one of the spaces beside it ("Move the tab group", "Move tab group ({name})" gives
|
||||
"Move tab group", "移动{name}标签组" gives "移动标签组"); a label left with no letter falls back
|
||||
to the English default. Two groups showing panels of the same title still get the same name.
|
||||
"Move tab group", "移动{name}标签组" gives "移动标签组"); a label left with no letter or digit falls
|
||||
back to the English default. Two groups showing panels of the same title still get the same name.
|
||||
|
||||
## Testing
|
||||
|
||||
|
||||
Reference in New Issue
Block a user