mirror of
https://github.com/l0ng-ai/tty7.git
synced 2026-09-22 00:02:23 +00:00
fix(sftp): let double-click open a file, not just a folder
The gesture ran sftp_enter_dir, which returns early for anything that is not a directory. Double-clicking a file — what every file browser, and every SFTP client, answers by opening it — did nothing at all: no transfer, no cursor change, no message. The row menu right beside it offers Download, and sftp_open_entry already handles both kinds. Point the gesture at that instead and drop the directory-only handler, which had no other caller. A download shows up in the transfers tray and can be cancelled from it, so the worst case is a click you can take back. Verified against a real SSH connection to localhost: double-clicking a file now lands it in ~/Downloads at the right size, and double-clicking a folder still navigates into it.
This commit is contained in:
+7
-8
@@ -515,13 +515,12 @@ impl Tty7App {
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub(crate) fn sftp_enter_dir(&mut self, entry: SftpEntry, cx: &mut Context<Self>) {
|
||||
if is_dir_like(&entry) {
|
||||
let target = remote_join(&self.sftp_panel.cwd, &entry.name);
|
||||
self.sftp_navigate(target, cx);
|
||||
}
|
||||
}
|
||||
|
||||
/// The double-click gesture and the row menu's first item both land here.
|
||||
/// They used to differ: double-click ran a directory-only handler, so
|
||||
/// double-clicking a file — the gesture every file browser answers by
|
||||
/// opening it — did nothing at all, with no cursor change or message to
|
||||
/// say why. A download is visible in the transfers tray and cancellable
|
||||
/// from it, so the worst case is a click you can take back.
|
||||
pub(crate) fn sftp_open_entry(&mut self, entry: SftpEntry, cx: &mut Context<Self>) {
|
||||
let target = remote_join(&self.sftp_panel.cwd, &entry.name);
|
||||
if is_dir_like(&entry) {
|
||||
@@ -1333,7 +1332,7 @@ impl Tty7App {
|
||||
.cursor_pointer()
|
||||
.hover(|s| s.bg(list_hover))
|
||||
.on_double_click(
|
||||
cx.listener(move |this, _, _w, cx| this.sftp_enter_dir(open_entry.clone(), cx)),
|
||||
cx.listener(move |this, _, _w, cx| this.sftp_open_entry(open_entry.clone(), cx)),
|
||||
)
|
||||
.child(
|
||||
Icon::new(icon)
|
||||
|
||||
Reference in New Issue
Block a user