This commit is contained in:
sxyazi 2024-10-24 08:52:29 +08:00
parent 68aa93b254
commit 279d9af329
No known key found for this signature in database
5 changed files with 7 additions and 7 deletions

View file

@ -36,11 +36,11 @@ impl IntoLua<'_> for BodyCd<'static> {
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
if let Some(Cow::Owned(url)) = Some(self.url).filter(|_| !self.dummy) {
lua.create_table_from([
("tab", self.tab.as_usize().into_lua(lua)?),
("tab", self.tab.get().into_lua(lua)?),
("url", lua.create_any_userdata(url)?.into_lua(lua)?),
])?
} else {
lua.create_table_from([("tab", self.tab.as_usize())])?
lua.create_table_from([("tab", self.tab.get())])?
}
.into_lua(lua)
}

View file

@ -32,11 +32,11 @@ impl IntoLua<'_> for BodyHover<'static> {
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
if let Some(Cow::Owned(url)) = self.url {
lua.create_table_from([
("tab", self.tab.as_usize().into_lua(lua)?),
("tab", self.tab.get().into_lua(lua)?),
("url", lua.create_any_userdata(url)?.into_lua(lua)?),
])?
} else {
lua.create_table_from([("tab", self.tab.as_usize())])?
lua.create_table_from([("tab", self.tab.get())])?
}
.into_lua(lua)
}

View file

@ -23,7 +23,7 @@ impl Tab {
pub(super) fn register(lua: &Lua) -> mlua::Result<()> {
lua.register_userdata_type::<Self>(|reg| {
reg.add_field_method_get("id", |_, me| Ok(me.id.as_usize()));
reg.add_field_method_get("id", |_, me| Ok(me.id.get()));
reg.add_method("name", |lua, me, ()| {
lua.create_string(me.current.url.name().as_encoded_bytes())
});

View file

@ -43,7 +43,7 @@ impl FilesOp {
pub fn prepare(cwd: &Url) -> Id {
let ticket = FILES_TICKET.next();
Self::Part(cwd.clone(), vec![], FILES_TICKET.next()).emit();
Self::Part(cwd.clone(), vec![], ticket).emit();
ticket
}

View file

@ -7,7 +7,7 @@ pub struct Id(usize);
impl Id {
#[inline]
pub fn as_usize(&self) -> usize { self.0 }
pub fn get(&self) -> usize { self.0 }
}
impl Display for Id {