diff --git a/crates/bevy_utils/src/short_names.rs b/crates/bevy_utils/src/short_names.rs index eab7b1b93eb6c..d8abbdcf1e635 100644 --- a/crates/bevy_utils/src/short_names.rs +++ b/crates/bevy_utils/src/short_names.rs @@ -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); @@ -107,4 +117,20 @@ mod name_formatting_tests { "do_mad_science, TypeSystemAbuse>".to_string() ); } + + #[test] + fn sub_path_after_closing_bracket() { + assert_eq!( + get_short_name("bevy_asset::assets::Assets::asset_event_system"), + "Assets::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() + ); + } }