Repository navigation
fix(vscode): update relative imports when moving or renaming flow files (#112) - #299
Open
heroking777 wants to merge 1 commit into
Open
heroking777 wants to merge 1 commit into
heroking777 wants to merge 1 commit into
Conversation
This branch has not been deployed
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
When files or folders containing Flyde flows (
.flyde) or custom code nodes (.flyde.ts,.flyde.js) are moved or renamed in VS Code, existing relative imports and file-sourced node instances break because their paths still point to the previous locations.This PR implements an automatic path updater in the VS Code extension:
vscode.workspace.onDidRenameFilesinvscode/src/extension.ts..flydefiles across the workspace.source.type === "file", including nested inline flows) as well as the flow'simportsmap..flydeflow file itself is moved to a different folder.vscode.WorkspaceEditand saves non-dirty open documents cleanly.@flyde/nodes, npm packages) and URL sources untouched.Testing & Verification
vscode/src/updateImportsOnMove.pure.test.ts:updates file-sourced instance when an imported node file is moved: verified child instance relative path update.updates relative file imports when the flow file itself is moved: verified parent relocation updating relative child path while keeping package sources intact.computes updated relative import across directory moves: verified directory rename rebasing.leaves package and external sources untouched: verified non-file sources remain unchanged.npx mocha -r ts-node/register src/updateImportsOnMove.pure.test.ts --ui tdd-> 4 passing (8ms).npx pnpm --dir vscode run compile-> Passed cleanly with 0 errors.npx mocha out/updateImportsOnMove.pure.test.js --ui tdd-> 4 passing (7ms).Fixes #112
/claim #112