From 458ca3b47b089ebc47ce140767cc656d4904f30b Mon Sep 17 00:00:00 2001 From: rolv Date: Thu, 15 Feb 2024 12:04:50 +0000 Subject: [PATCH] refactor(WIP): use new Lua APIs introduced with #674 --- yazi-plugin/preset/components/header.lua | 27 ++++++------------------ 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/yazi-plugin/preset/components/header.lua b/yazi-plugin/preset/components/header.lua index 5b6885e6..6558f02f 100644 --- a/yazi-plugin/preset/components/header.lua +++ b/yazi-plugin/preset/components/header.lua @@ -15,30 +15,17 @@ function Header:cwd() end function Header:selected_count() - local selected = 0 - local copied = 0 - local cut = 0 - - for _, f in ipairs(Folder:by_kind(Folder.CURRENT).window) do - if f:is_selected() then - selected = selected + 1 - end - - local is_yanked = f:is_yanked() - if is_yanked == 1 then - copied = copied + 1 - elseif is_yanked == 2 then - cut = cut + 1 - end - end + local selected = #cx.active.selected + local yanked = #cx.yanked + local is_cut = cx.yanked.is_cut local count local style - if cut > 0 then - count = cut + if is_cut then + count = yanked style = THEME.manager.count_cut - elseif copied > 0 then - count = copied + elseif yanked > 0 then + count = yanked style = THEME.manager.count_copied else count = selected