mirror of
https://github.com/sxyazi/yazi.git
synced 2025-01-02 13:50:15 +03:00
feat: size
linemode supports showing the file count for directories (#1591)
This commit is contained in:
parent
5f4779cc90
commit
f2dca99e43
@ -1,6 +1,7 @@
|
||||
use std::ops::Deref;
|
||||
|
||||
use mlua::{AnyUserData, Lua, UserDataFields, UserDataMethods};
|
||||
use yazi_plugin::url::UrlRef;
|
||||
|
||||
use super::{Config, Finder, Folder, Mode, Preview, Selected, SCOPE};
|
||||
|
||||
@ -41,6 +42,9 @@ impl Tab {
|
||||
me.parent.as_ref().map(|f| Folder::make(None, f, me)).transpose()
|
||||
});
|
||||
|
||||
reg.add_method("history", |_, me, url: UrlRef| {
|
||||
me.history.get(&url).map(|f| Folder::make(None, f, me)).transpose()
|
||||
});
|
||||
reg.add_field_method_get("selected", |_, me| Selected::make(&me.selected));
|
||||
|
||||
reg.add_field_method_get("preview", |_, me| Preview::make(me));
|
||||
|
@ -24,7 +24,12 @@ end
|
||||
|
||||
function Linemode:size()
|
||||
local size = self._file:size()
|
||||
return ui.Line(size and ya.readable_size(size) or "")
|
||||
if size then
|
||||
return ui.Line(ya.readable_size(size))
|
||||
else
|
||||
local folder = cx.active:history(self._file.url)
|
||||
return ui.Line(folder and tostring(#folder.files) or "")
|
||||
end
|
||||
end
|
||||
|
||||
function Linemode:ctime()
|
||||
|
Loading…
Reference in New Issue
Block a user