windows: Fix inconsistent separators in buffer headers and breadcrumbs (#38898)
Make `resolve_full_path` use the appropriate separators, and return a `String`. As part of fixing the fallout from that type change, this also fixes a bunch of places in the agent code that were using `std::path::Path` operations on paths that could be non-local, by changing them to operate instead on strings and use the project's `PathStyle`. This clears the way a bit for making `full_path` also return a string instead of a `PathBuf`, but I've left that for a follow-up. Release Notes: - N/A
This commit is contained in:
@@ -3782,13 +3782,17 @@ impl EditorElement {
|
||||
let file = for_excerpt.buffer.file();
|
||||
let can_open_excerpts = Editor::can_open_excerpts_in_file(file);
|
||||
let path_style = file.map(|file| file.path_style(cx));
|
||||
let relative_path = for_excerpt.buffer.resolve_file_path(cx, include_root);
|
||||
let filename = relative_path
|
||||
.as_ref()
|
||||
.and_then(|path| Some(path.file_name()?.to_string_lossy().to_string()));
|
||||
let parent_path = relative_path.as_ref().and_then(|path| {
|
||||
Some(path.parent()?.to_string_lossy().to_string() + path_style?.separator())
|
||||
});
|
||||
let relative_path = for_excerpt.buffer.resolve_file_path(include_root, cx);
|
||||
let (parent_path, filename) = if let Some(path) = &relative_path {
|
||||
if let Some(path_style) = path_style {
|
||||
let (dir, file_name) = path_style.split(path);
|
||||
(dir.map(|dir| dir.to_owned()), Some(file_name.to_owned()))
|
||||
} else {
|
||||
(None, Some(path.clone()))
|
||||
}
|
||||
} else {
|
||||
(None, None)
|
||||
};
|
||||
let focus_handle = editor.focus_handle(cx);
|
||||
let colors = cx.theme().colors();
|
||||
|
||||
|
||||
@@ -963,13 +963,12 @@ impl Item for Editor {
|
||||
buffer
|
||||
.snapshot()
|
||||
.resolve_file_path(
|
||||
cx,
|
||||
self.project
|
||||
.as_ref()
|
||||
.map(|project| project.read(cx).visible_worktrees(cx).count() > 1)
|
||||
.unwrap_or_default(),
|
||||
cx,
|
||||
)
|
||||
.map(|path| path.to_string_lossy().to_string())
|
||||
.unwrap_or_else(|| {
|
||||
if multibuffer.is_singleton() {
|
||||
multibuffer.title(cx).to_string()
|
||||
|
||||
Reference in New Issue
Block a user