refactor(file-browser): consolidate rename logic and prevent empty file names - #2560
Open
AuDevTist1C wants to merge 1 commit into
Open
refactor(file-browser): consolidate rename logic and prevent empty file names#2560AuDevTist1C wants to merge 1 commit into
AuDevTist1C wants to merge 1 commit into
Conversation
…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)
Contributor
Greptile SummaryThis PR consolidates the local and Termux rename flows while adding required-field validation to the rename prompt.
Confidence Score: 4/5The PR appears safe to merge, although Enter-key submission still bypasses the intended required-field feedback. The filesystem rename refactor preserves the existing state-update paths, while the only accepted concern is a non-blocking prompt inconsistency that silently cancels an empty Enter-key submission. Files Needing Attention: src/pages/fileBrowser/fileBrowser.js Important Files Changed
Reviews (1): Last reviewed commit: "refactor(file-browser): deduplicate rena..." | Re-trigger Greptile |
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.
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))