mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
fix windows build break
This commit is contained in:
parent
492929a0b8
commit
091e4d1aec
2 changed files with 27 additions and 22 deletions
|
|
@ -1,17 +1,23 @@
|
|||
use core::files::File;
|
||||
|
||||
use config::{MANAGER, THEME};
|
||||
use ratatui::{buffer::Buffer, layout::Rect, style::{Color, Modifier, Style}, text::{Line, Span}, widgets::{List, ListItem, Widget}};
|
||||
use ratatui::{
|
||||
buffer::Buffer,
|
||||
layout::Rect,
|
||||
style::{Color, Modifier, Style},
|
||||
text::{Line, Span},
|
||||
widgets::{List, ListItem, Widget},
|
||||
};
|
||||
use shared::short_path;
|
||||
|
||||
use crate::Ctx;
|
||||
|
||||
pub(super) struct Folder<'a> {
|
||||
cx: &'a Ctx,
|
||||
folder: &'a core::manager::Folder,
|
||||
is_preview: bool,
|
||||
cx: &'a Ctx,
|
||||
folder: &'a core::manager::Folder,
|
||||
is_preview: bool,
|
||||
is_selection: bool,
|
||||
is_find: bool,
|
||||
is_find: bool,
|
||||
}
|
||||
|
||||
impl<'a> Folder<'a> {
|
||||
|
|
@ -65,12 +71,15 @@ impl<'a> Folder<'a> {
|
|||
|
||||
let v = self.is_find.then_some(()).and_then(|_| {
|
||||
let finder = self.cx.manager.active().finder()?;
|
||||
#[cfg(target_os = "windows")]
|
||||
let (head, body, tail) = finder.explode(&short.name.to_string_lossy())?;
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let (head, body, tail) = finder.explode(short.name)?;
|
||||
|
||||
// TODO: to be configured by THEME?
|
||||
let style = Style::new().fg(Color::Rgb(255, 255, 50)).add_modifier(Modifier::ITALIC);
|
||||
Some(vec![
|
||||
Span::raw(short.prefix.join(head.as_ref()).display().to_string()),
|
||||
Span::raw(short.prefix.join(&head).display().to_string()),
|
||||
Span::styled(body, style),
|
||||
Span::raw(tail),
|
||||
])
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use shared::Url;
|
|||
use crate::files::Files;
|
||||
|
||||
pub struct Finder {
|
||||
query: Regex,
|
||||
query: Regex,
|
||||
matched: BTreeMap<Url, u8>,
|
||||
version: u64,
|
||||
}
|
||||
|
|
@ -111,31 +111,27 @@ impl Finder {
|
|||
|
||||
/// Explode the name into three parts: head, body, tail.
|
||||
#[inline]
|
||||
pub fn explode<'a>(&self, name: &'a OsStr) -> Option<(Cow<'a, str>, Cow<'a, str>, Cow<'a, str>)> {
|
||||
#[cfg(target_os = "windows")]
|
||||
let b = { name.to_string_lossy().as_bytes() };
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let b = {
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
name.as_bytes()
|
||||
};
|
||||
|
||||
pub fn explode<'a>(&self, name: &'a impl AsRef<str>) -> Option<(String, String, String)> {
|
||||
let b = name.as_ref().as_bytes();
|
||||
let range = self.query.find(b).map(|m| m.range())?;
|
||||
Some((
|
||||
String::from_utf8_lossy(&b[..range.start]),
|
||||
String::from_utf8_lossy(&b[range.start..range.end]),
|
||||
String::from_utf8_lossy(&b[range.end..]),
|
||||
String::from_utf8_lossy(&b[..range.start]).to_string(),
|
||||
String::from_utf8_lossy(&b[range.start..range.end]).to_string(),
|
||||
String::from_utf8_lossy(&b[range.end..]).to_string(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl Finder {
|
||||
#[inline]
|
||||
pub fn matched(&self) -> &BTreeMap<Url, u8> { &self.matched }
|
||||
pub fn matched(&self) -> &BTreeMap<Url, u8> {
|
||||
&self.matched
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn has_matched(&self) -> bool { !self.matched.is_empty() }
|
||||
pub fn has_matched(&self) -> bool {
|
||||
!self.matched.is_empty()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn matched_idx(&self, url: &Url) -> Option<u8> {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue