fix(vscode): rewrite .flyde imports on file rename/move (#112)#266
Open
dukunline-cyber wants to merge 1 commit into
Open
fix(vscode): rewrite .flyde imports on file rename/move (#112)#266dukunline-cyber wants to merge 1 commit into
dukunline-cyber wants to merge 1 commit into
Conversation
Closes flydelabs#112. Hooks into vscode.workspace.onDidRenameFiles and updates relative `source: { type: file, data: ... }` paths inside .flyde flow files so imports keep resolving after files are moved or renamed. Handles both directions: a .flyde flow being moved (rewrite its own imports relative to the new location) and an imported target being moved (walk all .flyde flows in the workspace and update references).
Author
|
/claim #112 |
Author
|
Hi, just checking in — any feedback on this PR? Happy to address any changes needed. |
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.
/claim #112
Closes #112.
Problem
When a file referenced by a
.flydeflow is moved to a different folder (or when a.flydeflow itself is moved), the relative path stored insource: { type: file, data: ... }breaks and the import fails to resolve.Reproduction matches the issue body: create a flow, import another flow, move either file -> import is broken until manually edited.
Fix
New module
vscode/src/flydeImportRewriter.tsregisters avscode.workspace.onDidRenameFileslistener that handles both directions:data:value inside the moved flow so the relative path resolves to the same absolute target it pointed at before the move..flydefiles in the workspace (excludingnode_modules) and rewrite anydata:value whose resolved absolute path matches the old location.The rewriter:
sourceblocks wheretype: file(leavespackageandinlinesources untouched).data:line, preserving indentation, quoting style, and surrounding YAML so diffs stay minimal and YAML-valid../relativepaths to match the existing convention in the repo's sample flows.Wired up via 4-line patch in
vscode/src/extension.ts(one import + one call insideactivate).Diff stats
vscode/src/flydeImportRewriter.ts- new file, 176 linesvscode/src/extension.ts- +4 linesVerification notes
onDidRenameFilesfires for both single-file renames and folder moves (folder moves emit one event per descendant), so folder-level reorganization is covered.website/playground-examples/*andtest-fixtures/.context.subscriptions.Happy to add unit tests around
mutateFileSourceDataif the maintainers want a follow-up.