From dc6af08714c928d52b461b99694874deee843862 Mon Sep 17 00:00:00 2001 From: emrebener Date: Fri, 22 May 2026 05:32:41 +0100 Subject: [PATCH] feat(plugin): double-click in current pane opens file or enters dir --- yazi-plugin/preset/components/current.lua | 24 +++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/yazi-plugin/preset/components/current.lua b/yazi-plugin/preset/components/current.lua index 74f73fe4..f69401c0 100644 --- a/yazi-plugin/preset/components/current.lua +++ b/yazi-plugin/preset/components/current.lua @@ -2,6 +2,8 @@ Current = { _id = "current", } +local last_click = { time = 0, url = nil } + function Current:new(area, tab) return setmetatable({ _area = area, @@ -54,9 +56,27 @@ function Current:click(event, up) end local y = event.y - self._area.y + 1 - if self._folder.window[y] then - Entity:new(self._folder.window[y]):click(event, up) + local f = self._folder.window[y] + if not f then + return end + + if event.is_left then + local delay = rt.mgr.mouse_double_click_delay or 0 + local now = ya.time() + local url = tostring(f.url) + if delay > 0 + and (now - last_click.time) * 1000 <= delay + and last_click.url == url + then + last_click.time = 0 + ya.emit("open", {}) + return + end + last_click = { time = now, url = url } + end + + Entity:new(f):click(event, up) end function Current:scroll(event, step) ya.emit("arrow", { step }) end