Bug 510277 - improvement of "makeSuggestedName" for hidden files in unix-like OS
Summary: improvement of "makeSuggestedName" for hidden files in unix-like OS
Status: REPORTED
Alias: None
Product: frameworks-kcoreaddons
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Michael Pyne
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-10-05 20:10 UTC by bd0
Modified: 2025-10-05 20:10 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bd0 2025-10-05 20:10:36 UTC
When duplicating a file or folder in the Dolphin file browser, the names are currently chosen as follows:

Original file "abc.txt", first duplicate: "abc copy.txt", second duplicate: "abc copy (1).txt"

Original file ".bashrc", first duplicate: ".bashrc copy", second duplicate: ". (1).bashrc copy"

The name of the first duplicate is generated by Dolphin itself (in "void DolphinView::duplicateSelectedItems()"), but the name of the second duplicate is then generated by the KCoreAddons (in "QString KFileUtils::makeSuggestedName(const QString &oldName)").

For "abc copy.txt" this looks ok, because all three files have the same prefix and are next to each other when sorting files by name.

But for the hidden file ".bashrc", the name of the second duplicate has a different prefix than the original file. The code does not seem to account for a leading dot in hidden files and folders.
A suggested name ".bashrc copy (1)" for the second duplicate would be more convenient, in my opinion.

Related code:

https://invent.kde.org/frameworks/kcoreaddons/-/blob/3618917edde2d200a6b34f099be151d21e1103f9/src/lib/io/kfileutils.cpp#L27-29

https://invent.kde.org/frameworks/kcoreaddons/-/blob/3618917edde2d200a6b34f099be151d21e1103f9/autotests/kfileutilstest.cpp#L37-38