This commit is contained in:
sxyazi 2023-10-07 01:14:21 +08:00
parent 4718c4ddee
commit 8cb91f344e
No known key found for this signature in database
2 changed files with 5 additions and 11 deletions

View file

@ -92,16 +92,16 @@ impl Finder {
/// Explode the name into three parts: head, body, tail. /// Explode the name into three parts: head, body, tail.
#[inline] #[inline]
pub fn highlighted(&self, name: &OsStr) -> Vec<Range<usize>> { pub fn highlighted(&self, name: &OsStr) -> Vec<Range<usize>> {
#[cfg(target_os = "windows")] #[cfg(windows)]
let found = self.query.find(name.to_string_lossy().as_bytes()); let found = self.query.find(name.to_string_lossy().as_bytes()).map(|m| m.range());
#[cfg(not(target_os = "windows"))] #[cfg(unix)]
let found = { let found = {
use std::os::unix::ffi::OsStrExt; use std::os::unix::ffi::OsStrExt;
self.query.find(name.as_bytes()) self.query.find(name.as_bytes()).map(|m| m.range())
}; };
found.map(|m| vec![m.range()]).unwrap_or_default() found.map(|r| vec![r]).unwrap_or_default()
} }
} }

View file

@ -54,7 +54,6 @@ impl<'a, 'b> Tab<'a, 'b> {
reg.add_field_function_get("window", |_, me| me.named_user_value::<Value>("window")); reg.add_field_function_get("window", |_, me| me.named_user_value::<Value>("window"));
reg.add_field_function_get("files", |_, me| me.named_user_value::<AnyUserData>("files")); reg.add_field_function_get("files", |_, me| me.named_user_value::<AnyUserData>("files"));
reg.add_field_function_get("hovered", |_, me| me.named_user_value::<Value>("hovered"));
})?; })?;
LUA.register_userdata_type::<core::files::Files>(|reg| { LUA.register_userdata_type::<core::files::Files>(|reg| {
@ -158,11 +157,6 @@ impl<'a, 'b> Tab<'a, 'b> {
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
)?; )?;
ud.set_named_user_value("files", self.files(&inner.files)?)?; ud.set_named_user_value("files", self.files(&inner.files)?)?;
// TODO: remove this
ud.set_named_user_value(
"hovered",
inner.hovered.as_ref().and_then(|h| self.file(999, h, inner).ok()),
)?;
Ok(ud) Ok(ud)
} }