Repository navigation
fix(vscode): preserve imports and editor saves across file renames - #289
Closed
gurjara450 wants to merge 1 commit into
Closed
gurjara450 wants to merge 1 commit into
gurjara450 wants to merge 1 commit into
Conversation
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.
Keep Flyde imports valid when files move in VS Code
Fixes #112
/claim #112
Renaming or moving an imported flow previously left its consumers pointing at the old path. An already-open visual editor could also save an old snapshot after the rename and restore that broken reference. For example, moving
ChildFlow.flydeintocomponents/now updates the parent import to./components/ChildFlow.flyde, resolves the child in the open editor, and keeps the repaired path through the next visual edit.The extension participates in
workspace.onWillRenameFilesand returns aWorkspaceEditbefore VS Code moves the files. It discovers flow documents across workspace roots and includes open flow buffers, then rewrites file references using each importer's original absolute path and the entire rename batch. This handles moved importers, independently moved dependencies, and folder descendants without matching similarly named sibling folders.The loader helper replaces only YAML scalar ranges. Comments, whitespace, quoting and unrelated values survive. It covers modern file sources, nested inline flows and legacy import keys; malformed or unsafe documents are logged and skipped independently. The rename participant reads current buffers and does not save them, so existing unsaved edits remain dirty.
Visual saves now carry a document version, run in sequence, and reject stale snapshots. External updates cancel pending saves and refresh the resolved editor state. If pre-move resolution produces temporary Error placeholders, the editor retries after a rename matching the unresolved import or the importer itself. Pending resolution survives visual saves because their serialized messages omit resolver metadata. Unrelated renames do not refresh the editor.
Validation
pnpm testpassed with 207 tests: core 135, loader 40, editor 1, nodes 1, VS Code extension host 26, and visual tests 4.ChildFlownode, absence of an Error placeholder after the move, and persistence through another visual edit and save without reopening the parent.Scope and evidence limits
This change handles local file renames delivered through VS Code's rename API. It does not observe arbitrary moves made outside VS Code. Unsafe YAML aliases, multiline references and conflicting rename batches are skipped with a log message rather than partially rewritten. Windows coverage here is path-helper coverage; no Windows GUI session was exercised. The recorded test results establish the stated automated checks. A separate 24-second demo uses three actual native editor screenshots: a prior visual save, a native Explorer dependency rename, and another visual save in the same open webview. Read-only saved YAML confirms the repaired source persists. These are static captured states, not a continuous screen recording.
Demo
import-renames-demo.mp4