/claim #112
Closes #112.
Problem
When a file referenced by a .flyde flow is moved to a different folder (or when a .flyde flow itself is moved), the relative path stored in source: { 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.ts registers a vscode.workspace.onDidRenameFiles listener that handles both directions:
- Moved file IS a .flyde flow -> rewrite each
data: value inside the moved flow so the relative path resolves to the same absolute target it pointed at before the move.
- Moved file is an IMPORTED target -> walk all
.flyde files in the workspace (excluding node_modules) and rewrite any data: value whose resolved absolute path matches the old location.
The rewriter:
- Operates only on
source blocks where type: file (leaves package and inline sources untouched).
- Edits only the
data: line, preserving indentation, quoting style, and surrounding YAML so diffs stay minimal and YAML-valid.
- Uses POSIX-style
./relative paths to match the existing convention in the repo’s sample flows.
- Is case-insensitive on win32 paths.
- Wraps every rewrite in try/catch so a single corrupt flow file can never crash the listener.
Wired up via 4-line patch in vscode/src/extension.ts (one import + one call inside activate).
Diff stats
vscode/src/flydeImportRewriter.ts - new file, 176 lines
vscode/src/extension.ts - +4 lines
Verification notes
- VSCode’s
onDidRenameFiles fires for both single-file renames and folder moves (folder moves emit one event per descendant), so folder-level reorganization is covered.
- The YAML walker is line-based and indentation-aware, so it tolerates the existing flow files in
website/playground-examples/* and test-fixtures/.
- Listener is disposed automatically because the subscription is pushed onto
context.subscriptions.
Happy to add unit tests around mutateFileSourceData if the maintainers want a follow-up.