[templates] generate child template name on copy (IDEA-298139)

GitOrigin-RevId: e2fd180f4b4ce703c72ca86bc670d7a7af9808ff
This commit is contained in:
Anna Kozlova
2022-07-20 13:48:54 +00:00
committed by intellij-monorepo-bot
parent 30c49600aa
commit ea586482fd
@@ -153,7 +153,10 @@ public final class AllFileTemplatesConfigurable implements SearchableConfigurabl
}
@SuppressWarnings("UnresolvedPropertyKey")
final String nameTemplate = IdeBundle.message("template.copy.N.of.T");
String name = MessageFormat.format(nameTemplate, "", selected.getName());
String name = FileTemplateBase.isChild(selected) && selected instanceof FileTemplateBase
? ((FileTemplateBase)selected).getChildName(selected.getChildren().length)
: MessageFormat.format(nameTemplate, "", selected.getName());
int i = 0;
while (names.contains(name)) {
name = MessageFormat.format(nameTemplate, ++i + " ", selected.getName());