Skip to content

fix: old folder persists in sidebar after drag-and-drop move#63

Open
chirag-bruno wants to merge 1 commit intousebruno:mainfrom
chirag-bruno:fix/drag-drop-old-folder-persists
Open

fix: old folder persists in sidebar after drag-and-drop move#63
chirag-bruno wants to merge 1 commit intousebruno:mainfrom
chirag-bruno:fix/drag-drop-old-folder-persists

Conversation

@chirag-bruno
Copy link
Copy Markdown
Collaborator

Summary

  • Broadcast unlinkDir event after directory move so the old folder is removed from the sidebar

Problem

When dragging a folder into another folder, the folder appeared in the new location but the old folder remained visible in the sidebar. The move couldn't be "reverted" because the stale folder entry persisted.

Root Cause

VS Code's createFileSystemWatcher only watches file patterns (**/*.bru / **/*.yml), not directory deletions. When removePath deletes a folder during a move, the watcher fires unlink events for the .bru files inside but not for the directory itself. The Redux store never received an unlinkDir event, so the empty folder node stayed in the collection tree.

Solution

After removePath completes in the renderer:move-item handler, check if the source was a directory and broadcast an unlinkDir event to all webviews. The existing collectionUnlinkDirectoryEvent reducer handles the removal from the Redux store.

Test plan

  • Drag a folder into another folder → verify old folder disappears from sidebar
  • Drag the folder back out → verify it moves correctly and old location is cleaned up
  • Drag a request file (not folder) → verify normal move still works
  • TypeScript typecheck passes

JIRA: https://usebruno.atlassian.net/browse/VSCODE-46

VS Code's file watcher only watches *.bru/*.yml files, not directories.
When a folder is moved via drag-and-drop, the watcher fires unlink
events for the files inside but not for the directory itself, leaving
the old empty folder visible in the sidebar.

After removePath completes in the move-item handler, broadcast an
unlinkDir event for the source directory so the Redux store removes
it from the collection tree.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants