Fix file extension retrieval for single-file worktrees

Previously, we used the file's 'path' method, which only returns the relative
path from the worktree root.
This commit is contained in:
Max Brunsfeld 2022-11-21 12:34:36 -08:00
parent 0078bea877
commit 55d3c09b6b

View file

@ -73,6 +73,7 @@ use std::{
mem,
num::NonZeroU32,
ops::{Deref, DerefMut, Range, RangeInclusive},
path::Path,
sync::Arc,
time::{Duration, Instant},
};
@ -6536,15 +6537,13 @@ impl Editor {
.as_singleton()
.and_then(|b| b.read(cx).file()),
) {
project.read(cx).client().report_event(
name,
json!({
"File Extension": file
.path()
let extension = Path::new(file.file_name(cx))
.extension()
.and_then(|e| e.to_str())
}),
);
.and_then(|e| e.to_str());
project
.read(cx)
.client()
.report_event(name, json!({ "File Extension": extension }));
}
}
}