Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions crates/bevy_utils/src/short_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,18 @@ pub fn get_short_name(full_name: &str) -> String {
let special_character =
&rest_of_string[special_character_index..=special_character_index];
parsed_name.push_str(special_character);
// Move the index just past the special character
index += special_character_index + 1;

match special_character {
">" | ")" | "]"
if rest_of_string[special_character_index + 1..].starts_with("::") =>
{
parsed_name.push_str("::");
// Move the index past the "::"
index += special_character_index + 3;
}
// Move the index just past the special character
_ => index += special_character_index + 1,
}
} else {
// If there are no special characters left, we're done!
parsed_name += collapse_type_name(rest_of_string);
Expand Down Expand Up @@ -107,4 +117,20 @@ mod name_formatting_tests {
"do_mad_science<Test<Tube>, TypeSystemAbuse>".to_string()
);
}

#[test]
fn sub_path_after_closing_bracket() {
assert_eq!(
get_short_name("bevy_asset::assets::Assets<bevy_scene::dynamic_scene::DynamicScene>::asset_event_system"),
"Assets<DynamicScene>::asset_event_system".to_string()
);
assert_eq!(
get_short_name("(String, String)::default"),
"(String, String)::default".to_string()
);
assert_eq!(
get_short_name("[i32; 16]::default"),
"[i32; 16]::default".to_string()
);
Comment on lines +127 to +134
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I don't know if these are technically possible. I'm pretty sure you're required to wrap them with angled brackets (i.e. <(String, String)>::default).

}
}