`NOTIFICATION_PATH_RENAMED` duplicate name with different node name casing than default
Tested versions
v4.7.2.stable.official.ed1daf0bf
System information
Linux Mint 22.3 Zena
Issue description
When using camelCase, snake_case or kebab-case options for editor/naming/node_name_casing project setting, and I add two nodes of same custom script class, the NOTIFICATION_PATH_RENAMED notification fires two times on editor, the first one when the node is created and the second one when the name changes according to the project setting and (should) validate duplicate names, adding a number suffix.
When using the default value PascalCase (maybe should be renamed to unchanged, more on that later) and adding two nodes via the global script class name Test, I have the following output:
[New Test node]
[NOTIFICATION_PATH_RENAMED] '' renamed to 'Test'
[NOTIFICATION_PATH_RENAMED] 'Test' renamed to 'Test'
'Test' entered tree
[New Test node]
[NOTIFICATION_PATH_RENAMED] '' renamed to 'Test'
[NOTIFICATION_PATH_RENAMED] 'Test' renamed to 'Test2'
'Test2' entered tree
As expected, the second node receives the second new name with the correct suffix. But when using other name casing options, for example snake_case, it gives the following output:
[New Test node]
[NOTIFICATION_PATH_RENAMED] '' renamed to 'Test'
[NOTIFICATION_PATH_RENAMED] 'Test' renamed to 'test'
'test' entered tree
[New Test node]
[NOTIFICATION_PATH_RENAMED] '' renamed to 'Test'
[NOTIFICATION_PATH_RENAMED] 'Test' renamed to 'test'
'test2' entered tree
Notice how the number suffix is only added after the node is already added to the tree, and the second new name doesn't have the suffix.
Also, about the PascalCase default option for the project setting, it doesn't actually enforce the casing. For example, if by class is named test, I would expect the default option rename it to Test, but this isn't what happens, it simply leaves the name casing untouched. The output for the default option is:
[New test node]
[NOTIFICATION_PATH_RENAMED] '' renamed to 'test'
[NOTIFICATION_PATH_RENAMED] 'test' renamed to 'test'
'test' entered tree
[New test node]
[NOTIFICATION_PATH_RENAMED] '' renamed to 'test'
[NOTIFICATION_PATH_RENAMED] 'test' renamed to 'test2'
'test2' entered tree
Notice how on the default value, the name casing is preserved, while adding the unique suffix before notifying NOTIFICATION_PATH_RENAMED.
Steps to reproduce
With a tool script, listen to NOTIFICATION_PATH_RENAMED, printing the new name.
Change editor/naming/node_name_casing project setting to one of camelCase, snake_case or kebab-case options.
Add two instances of the class script on the same parent node, to check the duplicate name validation behaviour.
Minimal reproduction project (MRP)
Source: godotengine/godot