fix: return early if no file is selected

This commit is contained in:
sxyazi
2024-06-21 21:34:19 +08:00
parent e26c524acc
commit a882e3828c

View File

@@ -1,12 +1,12 @@
local selected_or_hovered = ya.sync(function() local selected_or_hovered = ya.sync(function()
local tab, urls = cx.active, {} local tab, paths = cx.active, {}
for _, u in pairs(tab.selected) do for _, u in pairs(tab.selected) do
urls[#urls + 1] = tostring(u) paths[#paths + 1] = tostring(u)
end end
if #urls == 0 and tab.current.hovered then if #paths == 0 and tab.current.hovered then
urls[1] = tostring(tab.current.hovered.url) paths[1] = tostring(tab.current.hovered.url)
end end
return urls return paths
end) end)
return { return {
@@ -15,7 +15,7 @@ return {
local urls = selected_or_hovered() local urls = selected_or_hovered()
if #urls == 0 then if #urls == 0 then
ya.notify { title = "Chmod", content = "No file selected", level = "warn", timeout = 5 } return ya.notify { title = "Chmod", content = "No file selected", level = "warn", timeout = 5 }
end end
local value, event = ya.input { local value, event = ya.input {