aboutsummaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorDaniel Jankowski <daniel.jankowski@rub.de>2023-12-26 12:07:33 +0100
committerDaniel Jankowski <daniel.jankowski@rub.de>2023-12-26 12:07:33 +0100
commit7e939328f9ec45fbcd856474dd7c464e3ff402bb (patch)
tree9bb682a5d63c4214d14d6ab25f80091a54c64bea /src/widgets
parentchore: update cargo deps (diff)
downloadsl0pstatus-7e939328f9ec45fbcd856474dd7c464e3ff402bb.tar.gz
sl0pstatus-7e939328f9ec45fbcd856474dd7c464e3ff402bb.tar.xz
sl0pstatus-7e939328f9ec45fbcd856474dd7c464e3ff402bb.zip
feat: implement cache for dynamic command rendering
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/command.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/widgets/command.rs b/src/widgets/command.rs
index 22b2892..b9e9aba 100644
--- a/src/widgets/command.rs
+++ b/src/widgets/command.rs
@@ -8,9 +8,10 @@ use std::{
use chrono::{DateTime, Duration, Local};
use regex::Regex;
+#[cfg(not(feature = "bench"))]
use zellij_tile::shim::run_command;
-use crate::render::FormattedPart;
+use crate::render::{formatted_parts_from_string_cached, FormattedPart};
use crate::{config::ZellijState, widgets::widget::Widget};
@@ -113,7 +114,7 @@ impl Widget for CommandWidget {
}
fn render_dynamic_formatted_content(content: &str) -> String {
- FormattedPart::multiple_from_format_string(content)
+ formatted_parts_from_string_cached(content)
.iter()
.map(|fp| fp.format_string(&fp.content))
.collect::<Vec<String>>()
@@ -133,9 +134,11 @@ fn run_command_if_needed(command_config: CommandConfig, name: &str, state: &Zell
);
let command = commandline_parser(&command_config.command);
- let command = command.iter().map(|x| x.as_str()).collect::<Vec<&str>>();
#[cfg(not(feature = "bench"))]
- run_command(&command, context);
+ run_command(
+ &command.iter().map(|x| x.as_str()).collect::<Vec<&str>>(),
+ context,
+ );
}
}