Skip to content

A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.

Avoid delayed single selection after a plain row click on macOS

sunzhaozheng65157f5250c1
diff --git a/macos/Sources/RustyFiles/FileList.swift b/macos/Sources/RustyFiles/FileList.swift
index 8fde901e..bf650ae1 100644
--- a/macos/Sources/RustyFiles/FileList.swift
+++ b/macos/Sources/RustyFiles/FileList.swift
@@ -579,6 +579,22 @@ final class FileTableView: NSTableView, NSServicesMenuRequestor {
if selectedRowIndexes.contains(r) { deselectRow(r) } else { selectRowIndexes([r], byExtendingSelection: true) }
return
}
+ // Keep the entire selection available for native file dragging. Only take
+ // over when the next event is a plain release on the same selected row.
+ if r >= 0, event.clickCount == 1, selectedRowIndexes.count > 1,
+ selectedRowIndexes.contains(r),
+ event.modifierFlags.intersection([.command, .shift, .control, .option]).isEmpty,
+ let window,
+ let next = window.nextEvent(matching: [.leftMouseDragged, .leftMouseUp],
+ until: .distantFuture, inMode: .eventTracking, dequeue: false),
+ next.type == .leftMouseUp,
+ row(at: convert(next.locationInWindow, from: nil)) == r {
+ _ = window.nextEvent(matching: .leftMouseUp, until: .distantPast,
+ inMode: .eventTracking, dequeue: true)
+ window.makeFirstResponder(self)
+ selectRowIndexes(IndexSet(integer: r), byExtendingSelection: false)
+ return
+ }
super.mouseDown(with: event)
}