Remove separator! macro and make path! handle relative paths (#32527)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-06-13 00:32:29 -06:00 committed by GitHub
parent babf846ef9
commit 9cc82212b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 302 additions and 343 deletions

View file

@ -582,7 +582,7 @@ mod test {
use serde_json::json;
use settings::SettingsStore;
use smol::stream::StreamExt;
use util::{path, separator};
use util::path;
use super::collect_files;
@ -627,7 +627,7 @@ mod test {
.await
.unwrap();
assert!(result_1.text.starts_with(separator!("root/dir")));
assert!(result_1.text.starts_with(path!("root/dir")));
// 4 files + 2 directories
assert_eq!(result_1.sections.len(), 6);
@ -643,7 +643,7 @@ mod test {
cx.update(|cx| collect_files(project.clone(), &["root/dir*".to_string()], cx).boxed());
let result = SlashCommandOutput::from_event_stream(result).await.unwrap();
assert!(result.text.starts_with(separator!("root/dir")));
assert!(result.text.starts_with(path!("root/dir")));
// 5 files + 2 directories
assert_eq!(result.sections.len(), 7);
@ -691,24 +691,20 @@ mod test {
.unwrap();
// Sanity check
assert!(result.text.starts_with(separator!("zed/assets/themes\n")));
assert!(result.text.starts_with(path!("zed/assets/themes\n")));
assert_eq!(result.sections.len(), 7);
// Ensure that full file paths are included in the real output
assert!(
result
.text
.contains(separator!("zed/assets/themes/andromeda/LICENSE"))
.contains(path!("zed/assets/themes/andromeda/LICENSE"))
);
assert!(result.text.contains(path!("zed/assets/themes/ayu/LICENSE")));
assert!(
result
.text
.contains(separator!("zed/assets/themes/ayu/LICENSE"))
);
assert!(
result
.text
.contains(separator!("zed/assets/themes/summercamp/LICENSE"))
.contains(path!("zed/assets/themes/summercamp/LICENSE"))
);
assert_eq!(result.sections[5].label, "summercamp");
@ -716,17 +712,17 @@ mod test {
// Ensure that things are in descending order, with properly relativized paths
assert_eq!(
result.sections[0].label,
separator!("zed/assets/themes/andromeda/LICENSE")
path!("zed/assets/themes/andromeda/LICENSE")
);
assert_eq!(result.sections[1].label, "andromeda");
assert_eq!(
result.sections[2].label,
separator!("zed/assets/themes/ayu/LICENSE")
path!("zed/assets/themes/ayu/LICENSE")
);
assert_eq!(result.sections[3].label, "ayu");
assert_eq!(
result.sections[4].label,
separator!("zed/assets/themes/summercamp/LICENSE")
path!("zed/assets/themes/summercamp/LICENSE")
);
// Ensure that the project lasts until after the last await
@ -767,31 +763,28 @@ mod test {
.await
.unwrap();
assert!(result.text.starts_with(separator!("zed/assets/themes\n")));
assert_eq!(
result.sections[0].label,
separator!("zed/assets/themes/LICENSE")
);
assert!(result.text.starts_with(path!("zed/assets/themes\n")));
assert_eq!(result.sections[0].label, path!("zed/assets/themes/LICENSE"));
assert_eq!(
result.sections[1].label,
separator!("zed/assets/themes/summercamp/LICENSE")
path!("zed/assets/themes/summercamp/LICENSE")
);
assert_eq!(
result.sections[2].label,
separator!("zed/assets/themes/summercamp/subdir/LICENSE")
path!("zed/assets/themes/summercamp/subdir/LICENSE")
);
assert_eq!(
result.sections[3].label,
separator!("zed/assets/themes/summercamp/subdir/subsubdir/LICENSE")
path!("zed/assets/themes/summercamp/subdir/subsubdir/LICENSE")
);
assert_eq!(result.sections[4].label, "subsubdir");
assert_eq!(result.sections[5].label, "subdir");
assert_eq!(result.sections[6].label, "summercamp");
assert_eq!(result.sections[7].label, separator!("zed/assets/themes"));
assert_eq!(result.sections[7].label, path!("zed/assets/themes"));
assert_eq!(
result.text,
separator!(
path!(
"zed/assets/themes\n```zed/assets/themes/LICENSE\n1\n```\n\nsummercamp\n```zed/assets/themes/summercamp/LICENSE\n1\n```\n\nsubdir\n```zed/assets/themes/summercamp/subdir/LICENSE\n1\n```\n\nsubsubdir\n```zed/assets/themes/summercamp/subdir/subsubdir/LICENSE\n3\n```\n\n"
)
);