Fix file rename: pre-fill dialog and actually delete old file#1038
Merged
dail8859 merged 1 commit intodail8859:masterfrom May 2, 2026
Merged
Fix file rename: pre-fill dialog and actually delete old file#1038dail8859 merged 1 commit intodail8859:masterfrom
dail8859 merged 1 commit intodail8859:masterfrom
Conversation
Owner
|
Awesome! Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1034
Problem
Two bugs caused the rename feature (right-click tab → Rename) to misbehave:
Dialog opened with no pre-filled name.
MainWindow::renameFile()passed only the default directory toFileDialogHelpers::getSaveFileName.QFileDialogonly pre-fills the filename field when given a full file path, so the field was always empty.Old file was never deleted.
ScintillaNext::rename()checkedif (saveCopyAs(newFilePath))to decide whether to remove the original.saveCopyAsreturnsQFileDevice::FileError, whereNoError == 0(falsy). The condition was inverted — it entered the block only on error, so on success theQFile::removewas skipped and the old file was left on disk.The combination made it appear as if the file was "renamed" in the tab but the original remained untouched and a second copy appeared at the destination.
Video of the manual test below :
Screencast.from.2026-05-02.00-56-33.webm
Changes
src/dialogs/MainWindow.cppPass
editor->getFilePath()(the current file's full path) togetSaveFileNameinstead of the default directory.QFileDialognow navigates to the file's directory and pre-fills its name.src/ScintillaNext.cppChange the save-success check from
if (saveCopyAs(newFilePath))toif (saveCopyAs(newFilePath) == QFileDevice::NoError). The old file is now correctly removed after a successful copy.