Repository navigation
Add drag-and-drop support for files and folders in Local compare and Compare view - #33
Conversation
- Add file-drop helper (src/lib/app/file-drop.ts) to detect OS file drag payloads, resolve dropped paths via getDroppedFilePath, and determine left/right drop targets in the compare viewer. - Enable drag-and-drop across the entire Left and Right target panes in Local compare (PickerPane) to open parent folders and select dropped files, or open and select dropped folders. - Enable drag-and-drop on the Compare screen (CompareScreen) with left/right drop-zone highlights, supporting single-side replacement and simultaneous two-item drops to immediately re-run local comparisons. - Refactor shared path selection logic into applyPathToPane in App.svelte so file dialogs and drag-and-drop follow the same code path. - Add Vitest unit tests in src/lib/app/file-drop.test.ts.
- One dropped item goes to the side it was dropped on, two items of the same kind become left and right; mixed or missing items show an error. - On the compare screen, a single drop only replaces one side of a local compare. Git and GitHub compares no longer silently reload themselves instead of comparing the dropped items. - Unsaved edits are confirmed before any pane state changes. - The highlighted half and the receiving side now use the same rect, drawn as a fixed overlay so the compare layout is not repositioned. - Drag tracking lives in one shared fileDropZone action. - The main window refuses to navigate away from the app, so a drop outside a drop zone can no longer replace the app with the dropped file.
After a restore or a changed setup pane, a single drop could compare against a pane target that was not the one being shown. Drops are also ignored while the compare view is hidden under settings.
- Scroll PickerPane's virtualized entry list into view and highlight the row when pane.selectedTargetPath updates after dropping a file. - Add findRowIndexByPath and computeRowScrollTop helpers in src/lib/app/file-drop.ts and cover them in src/lib/app/file-drop.test.ts.
…mpares A slower drop no longer overrides a newer drop or a switch away from the compare screen. A single folder dropped onto a multi-folder compare now asks for two folders instead of prompting about unsaved edits first and failing on the folder count afterwards.
…tale The left/right split ignored the directory sidebar and side panels, so part of the left diff counted as right. A compare started while the drop waited for path checks or the unsaved dialog now also cancels the drop.
- Normalize forward and backward slashes when comparing dropped paths in findRowIndexByPath (src/lib/app/file-drop.ts). - Update unit tests in src/lib/app/file-drop.test.ts to cover mixed slash formats.
… switching A drop that waited while another compare started and finished no longer replaces it, and an older setup drop no longer overrides a newer one. Edits typed while the dropped folders were opening now stop the switch instead of being lost with the old session.
A row removed under the cursor during the drag never sends dragleave, so the highlight could stay on after the drag left.
…com/ElektroStudios/diffly into feature/drag-and-drop-local-compare
…com/ElektroStudios/diffly into feature/drag-and-drop-local-compare
The last merge on this branch brought back the old per-pane drag handlers next to the shared fileDropZone action and a test for the removed resolveCompareDropSide, so check and tests failed. The picker uses the shared action again and keeps the new scroll-to-selected-target behavior. - Dropped paths are no longer trimmed: on macOS and Linux a trailing space is part of the name. - Row lookup only normalizes separators; names stay case sensitive. - A drop during a running compare now explains why nothing happened.
# Conflicts: # src/App.svelte # src/lib/screens/CompareScreen.svelte
|
Thanks, merged! I reworked the drop logic before merging:
About your two later commits: the merge |
Note on Drag-and-Drop & Autoscroll Follow-ups (#33)I had planned to keep refining the drag-and-drop and autoscroll behavior for #33 (Add drag-and-drop support for files and folders in Local compare and Compare view):
Because there are already frequent commits and moving changes landing around this work, I don't have time to keep chasing every new change and re-adapting updates right now. I'll try as I can. Thank you for merging and committing changes to make it better! Oh, I just noticed this issue has already been fixed in one of the later commits—thanks a lot! Leaving the current state here as-is. |
Summary
PickerPane.svelte):CompareScreen.svelte) with a visual left/right half highlight:getDroppedFilePath(webUtils.getPathForFile) preload bridge and unified path selection viaapplyPathToPaneinApp.svelte.src/lib/app/file-drop.test.ts.Validation
npm run checknpm testnpm run electron:packageNotes
I have no experience with TypeScript, Svelte, or Electron, so I delegated the code implementation to an AI assistant and verified the behavior locally on Windows. Please review carefully for any idiomatic improvements or edge cases I might have missed.