Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Truncate target name in project filename formatting
Richie McIlroy4d3f65398f85
diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rsindex cb24c1afd..6d39fbf48 100644--- a/apps/desktop/src-tauri/src/recording.rs+++ b/apps/desktop/src-tauri/src/recording.rs@@ -376,8 +376,22 @@ pub fn format_project_name<'a>(datetime: Option<chrono::DateTime<chrono::Local>>,) -> String {const DEFAULT_FILENAME_TEMPLATE: &str = "{target_name} ({target_kind}) {date} {time}";+ const MAX_TARGET_NAME_CHARS: usize = 180;let datetime = datetime.unwrap_or(chrono::Local::now());+ let truncated_target_name: std::borrow::Cow<'_, str> =+ if target_name.chars().count() > MAX_TARGET_NAME_CHARS {+ std::borrow::Cow::Owned(+ target_name+ .chars()+ .take(MAX_TARGET_NAME_CHARS)+ .collect::<String>()+ + "...",+ )+ } else {+ std::borrow::Cow::Borrowed(target_name)+ };+lazy_static! {static ref DATE_REGEX: Regex = Regex::new(r"\{date(?::([^}]+))?\}").unwrap();static ref TIME_REGEX: Regex = Regex::new(r"\{time(?::([^}]+))?\}").unwrap();@@ -402,7 +416,7 @@ pub fn format_project_name<'a>(};let result = AC- .try_replace_all(haystack, &[recording_mode, mode, target_kind, target_name])+ .try_replace_all(haystack, &[recording_mode, mode, target_kind, &truncated_target_name]).expect("AhoCorasick replace should never fail with default configuration");let result = DATE_REGEX.replace_all(&result, |caps: ®ex::Captures| {