fix: update import paths when .flyde files are moved or renamed#256
Open
maoshuorz wants to merge 1 commit intoflydelabs:mainfrom
Open
fix: update import paths when .flyde files are moved or renamed#256maoshuorz wants to merge 1 commit intoflydelabs:mainfrom
maoshuorz wants to merge 1 commit intoflydelabs:mainfrom
Conversation
When a .flyde or .flyde.ts file is moved/renamed in VS Code, all other .flyde files that reference it via source.type "file" now have their relative paths automatically updated to point to the new location. This handles three scenarios: 1. An imported file is moved — all referencing flows are updated 2. A flow file itself is moved — its internal file references are recalculated relative to the new location 3. Both imported and importing files move simultaneously — paths are resolved correctly using the new locations Fixes flydelabs#112
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.
Summary
Fixes #112 — broken imports after moving files.
/claim #112
When a
.flydeor.flyde.tsfile is moved or renamed in VS Code, all.flydefiles that reference it viasource.type: "file"now have their relative paths automatically updated to point to the new location.Problem
When a user creates a flow that imports another
.flydefile (e.g.,./ChildFlow.flyde) and then moves that imported file to a different folder, the import path breaks because the relative path stored insource.datais no longer valid.Solution
Added a
workspace.onDidRenameFileshandler in the VS Code extension (updateImportsOnFileMove.ts) that intercepts file move/rename events and automatically updates import paths in all affected.flydefiles.Three scenarios handled:
Imported file is moved — All
.flydefiles referencing the moved file get theirsource.datapaths recalculated relative to the new location.Flow file itself is moved to a different directory — Its internal
source.type: "file"references are recalculated relative to the new directory.Both files move simultaneously — The handler cross-references the rename list so paths resolve correctly even when multiple related files are moved at once.
Implementation details:
workspace.onDidRenameFiles(fires after the move completes).flydeand.flyde.tsfilesyamllibrary (already a dependency via@flyde/loader)./subfolder/Child.flyde) matching the existing conventionFiles changed
vscode/src/updateImportsOnFileMove.ts— New file with the import update logicvscode/src/extension.ts— Registers the handler on extension activationTest plan
Parent.flydethat imports./Child.flydeviasource: { type: file, data: ./Child.flyde }Child.flydeto a subfolder — verifyParent.flydeupdates to./subfolder/Child.flydeParent.flydeto a subfolder — verify its reference updates relative to new location.flyde.tscode node file — verify referencing flows update.flydefiles are modified