From 2fa958aa79e62dbf263bae70388bf85a2cfb66c3 Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Thu, 1 Jan 2026 21:26:02 -0800 Subject: [PATCH] Remove generics from the user-facing name for the Vector data type --- .../document/node_graph/node_properties.rs | 12 ++-------- node-graph/libraries/core-types/src/types.rs | 23 ++++++++++++++----- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/editor/src/messages/portfolio/document/node_graph/node_properties.rs b/editor/src/messages/portfolio/document/node_graph/node_properties.rs index e05145f3..2ea96334 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_properties.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_properties.rs @@ -233,15 +233,7 @@ pub(crate) fn property_from_type( widgets.extend_from_slice(&[ Separator::new(SeparatorStyle::Unrelated).widget_instance(), TextLabel::new("-") - .tooltip_label(format!( - "Data Type: {}", - concrete_type - .alias - .as_deref() - // TODO: Avoid needing to remove spaces here by fixing how `alias` is generated - .map(|s| s.to_string().replace(" ", "")) - .unwrap_or_else(|| graphene_std::format_type(concrete_type.name.as_ref())), - )) + .tooltip_label(format!("Data Type: {concrete_type}")) .tooltip_description("This data can only be supplied through the node graph because no widget exists for its type.") .widget_instance(), ]); @@ -251,7 +243,7 @@ pub(crate) fn property_from_type( } } } - Type::Generic(_) => vec![TextLabel::new("Generic type (not supported)").widget_instance()].into(), + Type::Generic(_) => vec![TextLabel::new("Generic Type (Not Supported)").widget_instance()].into(), Type::Fn(_, out) => return property_from_type(node_id, index, out, number_options, unit, display_decimal_places, step, context), Type::Future(out) => return property_from_type(node_id, index, out, number_options, unit, display_decimal_places, step, context), }; diff --git a/node-graph/libraries/core-types/src/types.rs b/node-graph/libraries/core-types/src/types.rs index b8bb9873..f964e191 100644 --- a/node-graph/libraries/core-types/src/types.rs +++ b/node-graph/libraries/core-types/src/types.rs @@ -216,6 +216,13 @@ impl std::hash::Hash for TypeDescriptor { } } +impl std::fmt::Display for TypeDescriptor { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let text = make_type_user_readable(&format_type(&self.name)); + write!(f, "{text}") + } +} + impl PartialEq for TypeDescriptor { fn eq(&self, other: &Self) -> bool { match (self.id, other.id) { @@ -361,9 +368,13 @@ pub fn format_type(ty: &str) -> String { .join("<") } +pub fn make_type_user_readable(ty: &str) -> String { + ty.replace("Option>", "Context").replace("Vector>>", "Vector") +} + impl std::fmt::Debug for Type { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let result = match self { + let text = match self { Self::Generic(name) => name.to_string(), #[cfg(feature = "type_id_logging")] Self::Concrete(ty) => format!("Concrete<{}, {:?}>", ty.name, ty.id), @@ -372,20 +383,20 @@ impl std::fmt::Debug for Type { Self::Fn(call_arg, return_value) => format!("{return_value:?} called with {call_arg:?}"), Self::Future(ty) => format!("{ty:?}"), }; - let result = result.replace("Option>", "Context"); - write!(f, "{result}") + let text = make_type_user_readable(&text); + write!(f, "{text}") } } impl std::fmt::Display for Type { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let result = match self { + let text = match self { Type::Generic(name) => name.to_string(), Type::Concrete(ty) => format_type(&ty.name), Type::Fn(call_arg, return_value) => format!("{return_value} called with {call_arg}"), Type::Future(ty) => ty.to_string(), }; - let result = result.replace("Option>", "Context"); - write!(f, "{result}") + let text = make_type_user_readable(&text); + write!(f, "{text}") } }