From 5cde024fc9e5c112578621eeeed54eeb85ebd7ab Mon Sep 17 00:00:00 2001 From: YimingWu Date: Mon, 29 Sep 2025 17:37:17 +0200 Subject: [PATCH] Fix #146413: Truncate socket names only if space is present after prefix In 95259228d9394477d1dda6d56e37b79bd55905de an optimization was made to simplify geometry nodes socket names on panels when they contain the exact group title as prefix, but this leads to issue where `Opening` can be truncated as `ing` which is not desired. Now will check if a space character is present after the prefix, then do the truncation. Note that this implementation still doesn't truncate `CamelCase` or any CJK name strings because they don't use the space character as separator. Pull Request: https://projects.blender.org/blender/blender/pulls/146973 --- .../blender/nodes/intern/geometry_nodes_caller_ui.cc | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/source/blender/nodes/intern/geometry_nodes_caller_ui.cc b/source/blender/nodes/intern/geometry_nodes_caller_ui.cc index d478efc7034..1ff3ecd5e26 100644 --- a/source/blender/nodes/intern/geometry_nodes_caller_ui.cc +++ b/source/blender/nodes/intern/geometry_nodes_caller_ui.cc @@ -508,13 +508,10 @@ static void draw_property_for_socket(DrawGroupInputsContext &ctx, * the prefix so it appears less verbose. */ if (parent_name.has_value()) { const StringRef prefix_to_remove = *parent_name; - int pos = name.find(prefix_to_remove); - if (pos == 0 && name != prefix_to_remove) { - /* Needs to trim remaining space characters if any. Use the `trim()` from `StringRefNull` - * because std::string doesn't have a built-in `trim()` yet. If the property name is the - * same as parent panel's name then keep the name, otherwise the name would be an empty - * string which messes up the UI. */ - name = StringRefNull(name.substr(prefix_to_remove.size())).trim(); + const int prefix_size = prefix_to_remove.size(); + const int pos = name.find(prefix_to_remove); + if (pos == 0 && name.size() > prefix_size && name[prefix_size] == ' ') { + name = name.substr(prefix_size + 1); } }