wip: override prototypes with cli preview

This commit is contained in:
Alexandre Pasmantier 2025-05-04 23:18:26 +02:00
parent 5afb3c5e7e
commit fc3f24fd89
2 changed files with 9 additions and 3 deletions

View File

@ -80,7 +80,7 @@ impl From<Cli> for PostProcessedCli {
offset_expr: None, offset_expr: None,
}); });
let channel: CableChannelPrototype; let mut channel: CableChannelPrototype;
let working_directory: Option<String>; let working_directory: Option<String>;
let cable_channels = cable::load_cable_channels().unwrap_or_default(); let cable_channels = cable::load_cable_channels().unwrap_or_default();
@ -118,6 +118,12 @@ impl From<Cli> for PostProcessedCli {
} }
} }
if let Some(preview_cmd) = &preview_command {
channel.preview_command = Some(preview_cmd.command.clone());
channel.preview_delimiter = Some(preview_cmd.delimiter.clone());
channel.preview_offset = preview_cmd.offset_expr.clone();
}
Self { Self {
channel, channel,
preview_command, preview_command,

View File

@ -30,8 +30,8 @@ impl Previewer {
// fast for most standard file sizes, plus we're caching the previews, // fast for most standard file sizes, plus we're caching the previews,
// I'm not sure the extra complexity is worth it. // I'm not sure the extra complexity is worth it.
pub fn handle_request(&mut self, entry: &Entry) -> Option<Arc<Preview>> { pub fn handle_request(&mut self, entry: &Entry) -> Option<Arc<Preview>> {
// check if we have a preview for the current request // check if we have a preview in cache for the current request
if let Some(preview) = self.preview(entry) { if let Some(preview) = self.cached(entry) {
return Some(preview); return Some(preview);
} }