refactor(file-browser): consolidate rename logic and prevent empty file names - #2560
refactor(file-browser): consolidate rename logic and prevent empty file names#2560AuDevTist1C wants to merge 1 commit into
Conversation
Greptile SummaryRefactors file and folder renaming to share post-rename state updates.
Confidence Score: 4/5The PR does not yet appear safe to merge because empty rename submissions still bypass the intended required-field enforcement and silently cancel. Although greptile replied that the issue was invalid because the regex disabled submission, FILE_NAME_REGEX accepts the empty string, so the enabled form submission resolves an empty value and the rename handler silently exits. Files Needing Attention: src/pages/fileBrowser/fileBrowser.js; src/dialogs/prompt.js; src/lib/config.js Important Files Changed
Reviews (2): Last reviewed commit: "refactor(file-browser): deduplicate rena..." | Re-trigger Greptile |
bajrangCoder
left a comment
There was a problem hiding this comment.
Enter bypasses the new required validation.
FILE_NAME_REGEX accepts an empty string, so clearing the field enables submission. Pressing Enter runs prompt onsubmit, which resolves "" without checking options.required or hiding the prompt. The rename is cancelled by the caller, but the dialog remains in a resolved, non-functional state.
8380be3 to
cf04325
Compare
30873f3 to
6ce70f4
Compare
d6f13d3 to
3cf8973
Compare
…lidation - Enforce `required: true` on the file/folder rename prompt to prevent empty inputs. - Unify post-rename side effects (recents update, editor tab URI sync, tree state, success toast, reload) across standard and Termux filesystem paths. - Wrap standard filesystem rename execution inside the master try-catch block to gracefully capture errors. (AI generated commit message)
3cf8973 to
fc1cf4a
Compare
This PR refactors the file/folder rename control flow in
fileBrowser.jsto reduce code duplication and adds explicit non-empty input enforcement to the rename prompt.Changes
1. Enforce Non-Empty Rename Input
required: trueto the rename prompt options.match: config.FILE_NAME_REGEX, addingrequired: trueprevents submitting empty string values ("").2. Refactor and Deduplicate
renameFileFlowrenameFile(newname)to follow the DRY (Don't Repeat Yourself) principle.isTermuxUrl(url)) contained duplicate state updates (recents.removeFile,recents.addFile,editorManager.getFile,openFolder.renameItem,toast, andreload()) and exited early.newUrlwithin anif / elseblock. Successful executions fall through to a single set of state updates and UI refreshes.3. Unified Error Handling
fs.renameTo(newname)) inside the mastertry...catchblock to handle errors consistently alongside the Termux branch.(PR name and description are AI generated (Gemini 3.6 Flash))