SUMMARY Using the Rename function to rename a file to such a name that happens to be an existing directory leads to loss of file contents. STEPS TO REPRODUCE 1) In some directory, make a text file with any content and a subdirectory 2) Open the text file in Kate or Kwrite 3) Use File -> File actions -> Rename, enter the name of the existing subdirectory OBSERVED RESULT The editor tab is reopened with the new path, but the buffer is empty and an error is shown: "The file <...> could not be loaded, as it was not possible to read from it. Check if you have read access to this file." The original file is gone, contents of the file are lost. Undo is not available. EXPECTED RESULT Show an error, keep the original file. The error message could explain the problem better. SOFTWARE/OS VERSIONS Application: Kate / KWrite 25.04.2 OS: Debian testing (trixie) Filesystem: ext4 KDE Plasma Version: 6.3.5 KDE Frameworks Version: 6.13.0 Qt Version: 6.8.2
There is no data loss, the file gets moved in the directory just.
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1819
Thank you for looking into this. I apologize for my mistake, indeed the file is moved into the directory and not lost. So the actual problem is that the moved file is not re-opened properly afterwards, instead giving an error. Moving could also be considered undesirable when the user only wanted to rename without realizing there is a directory, but this would be a minor issue.
Indeed, the move is really unexpected. It makes sense if you think a bit deeper since renaming is just moving a file.
Git commit 2e9f41b871d333bcdb7b0ef98a35d214e87263f0 by Christoph Cullmann, on behalf of Waqar Ahmed. Committed on 14/07/2025 at 18:14. Pushed by cullmann into branch 'master'. Use KIO::moveAs to rename file This will error out if there is an existing dir with the same name M +1 -1 apps/lib/katefileactions.cpp https://invent.kde.org/utilities/kate/-/commit/2e9f41b871d333bcdb7b0ef98a35d214e87263f0
Git commit 5e5238d29e7e0880c45df7ea1078baaa57ca530b by Christoph Cullmann. Committed on 14/07/2025 at 20:21. Pushed by cullmann into branch 'release/25.08'. Use KIO::moveAs to rename file This will error out if there is an existing dir with the same name (cherry picked from commit 2e9f41b871d333bcdb7b0ef98a35d214e87263f0) Co-authored-by: Waqar Ahmed <waqar.17a@gmail.com> M +1 -1 apps/lib/katefileactions.cpp https://invent.kde.org/utilities/kate/-/commit/5e5238d29e7e0880c45df7ea1078baaa57ca530b