Filter out non-json files when loading conversations (#2688)

Fixes
https://linear.app/zed-industries/issue/Z-2540/filter-out-non-conversation-files-from-the-assistant-history
This commit is contained in:
Antonio Scandurra 2023-07-06 16:51:52 +02:00 committed by GitHub
commit b4ed0347b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,6 +12,7 @@ use regex::Regex;
use serde::{Deserialize, Serialize};
use std::{
cmp::Reverse,
ffi::OsStr,
fmt::{self, Display},
path::PathBuf,
sync::Arc,
@ -80,6 +81,9 @@ impl SavedConversationMetadata {
let mut conversations = Vec::<SavedConversationMetadata>::new();
while let Some(path) = paths.next().await {
let path = path?;
if path.extension() != Some(OsStr::new("json")) {
continue;
}
let pattern = r" - \d+.zed.json$";
let re = Regex::new(pattern).unwrap();