Better display labels for external files
This commit is contained in:
parent
508533ebb7
commit
cf2bbfc85a
3 changed files with 33 additions and 35 deletions
|
@ -101,11 +101,11 @@ fn toggle_file_finder(workspace: &mut Workspace, _: &Toggle, cx: &mut ViewContex
|
||||||
});
|
});
|
||||||
|
|
||||||
// if exists, bubble the currently opened path to the top
|
// if exists, bubble the currently opened path to the top
|
||||||
let history_items = dbg!(dbg!(currently_opened_path.clone())
|
let history_items = currently_opened_path
|
||||||
|
.clone()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(
|
.chain(
|
||||||
workspace
|
workspace
|
||||||
// TODO kb history contains empty paths
|
|
||||||
.recent_navigation_history(Some(MAX_RECENT_SELECTIONS), cx)
|
.recent_navigation_history(Some(MAX_RECENT_SELECTIONS), cx)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|(history_path, _)| {
|
.filter(|(history_path, _)| {
|
||||||
|
@ -116,7 +116,7 @@ fn toggle_file_finder(workspace: &mut Workspace, _: &Toggle, cx: &mut ViewContex
|
||||||
})
|
})
|
||||||
.map(|(history_path, abs_path)| FoundPath::new(history_path, abs_path)),
|
.map(|(history_path, abs_path)| FoundPath::new(history_path, abs_path)),
|
||||||
)
|
)
|
||||||
.collect());
|
.collect();
|
||||||
|
|
||||||
let project = workspace.project().clone();
|
let project = workspace.project().clone();
|
||||||
let workspace = cx.handle().downgrade();
|
let workspace = cx.handle().downgrade();
|
||||||
|
|
|
@ -492,7 +492,7 @@ impl Pane {
|
||||||
|
|
||||||
if let Some((project_path, entry)) = to_load {
|
if let Some((project_path, entry)) = to_load {
|
||||||
// If the item was no longer present, then load it again from its previous path.
|
// If the item was no longer present, then load it again from its previous path.
|
||||||
let task = workspace.load_path(project_path.clone(), cx);
|
let task = workspace.load_path(project_path, cx);
|
||||||
cx.spawn(|workspace, mut cx| async move {
|
cx.spawn(|workspace, mut cx| async move {
|
||||||
let task = task.await;
|
let task = task.await;
|
||||||
let mut navigated = false;
|
let mut navigated = false;
|
||||||
|
@ -510,7 +510,6 @@ impl Pane {
|
||||||
workspace,
|
workspace,
|
||||||
pane.clone(),
|
pane.clone(),
|
||||||
project_entry_id,
|
project_entry_id,
|
||||||
&project_path,
|
|
||||||
true,
|
true,
|
||||||
cx,
|
cx,
|
||||||
build_item,
|
build_item,
|
||||||
|
@ -547,7 +546,6 @@ impl Pane {
|
||||||
workspace: &mut Workspace,
|
workspace: &mut Workspace,
|
||||||
pane: ViewHandle<Pane>,
|
pane: ViewHandle<Pane>,
|
||||||
project_entry_id: ProjectEntryId,
|
project_entry_id: ProjectEntryId,
|
||||||
project_path: &ProjectPath,
|
|
||||||
focus_item: bool,
|
focus_item: bool,
|
||||||
cx: &mut ViewContext<Workspace>,
|
cx: &mut ViewContext<Workspace>,
|
||||||
build_item: impl FnOnce(&mut ViewContext<Pane>) -> Box<dyn ItemHandle>,
|
build_item: impl FnOnce(&mut ViewContext<Pane>) -> Box<dyn ItemHandle>,
|
||||||
|
@ -580,15 +578,6 @@ impl Pane {
|
||||||
None,
|
None,
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
{
|
|
||||||
let abs_path = workspace.absolute_path(project_path, cx);
|
|
||||||
pane.read(cx)
|
|
||||||
.nav_history
|
|
||||||
.borrow_mut()
|
|
||||||
.paths_by_item
|
|
||||||
.insert(new_item.id(), (project_path.clone(), abs_path));
|
|
||||||
}
|
|
||||||
|
|
||||||
new_item
|
new_item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -602,6 +591,20 @@ impl Pane {
|
||||||
destination_index: Option<usize>,
|
destination_index: Option<usize>,
|
||||||
cx: &mut ViewContext<Workspace>,
|
cx: &mut ViewContext<Workspace>,
|
||||||
) {
|
) {
|
||||||
|
if item.is_singleton(cx) {
|
||||||
|
if let Some(&entry_id) = item.project_entry_ids(cx).get(0) {
|
||||||
|
if let Some(project_path) =
|
||||||
|
workspace.project().read(cx).path_for_entry(entry_id, cx)
|
||||||
|
{
|
||||||
|
let abs_path = workspace.absolute_path(&project_path, cx);
|
||||||
|
pane.read(cx)
|
||||||
|
.nav_history
|
||||||
|
.borrow_mut()
|
||||||
|
.paths_by_item
|
||||||
|
.insert(item.id(), (project_path, abs_path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// If no destination index is specified, add or move the item after the active item.
|
// If no destination index is specified, add or move the item after the active item.
|
||||||
let mut insertion_index = {
|
let mut insertion_index = {
|
||||||
let pane = pane.read(cx);
|
let pane = pane.read(cx);
|
||||||
|
@ -1984,7 +1987,6 @@ impl PaneNavHistory {
|
||||||
f(entry, project_and_abs_path.clone());
|
f(entry, project_and_abs_path.clone());
|
||||||
} else if let Some(item) = entry.item.upgrade(cx) {
|
} else if let Some(item) = entry.item.upgrade(cx) {
|
||||||
if let Some(path) = item.project_path(cx) {
|
if let Some(path) = item.project_path(cx) {
|
||||||
// TODO kb ??? this should be the full path
|
|
||||||
f(entry, (path, None));
|
f(entry, (path, None));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1306,14 +1306,19 @@ impl Workspace {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn absolute_path(&self, project_path: &ProjectPath, cx: &AppContext) -> Option<PathBuf> {
|
pub fn absolute_path(&self, project_path: &ProjectPath, cx: &AppContext) -> Option<PathBuf> {
|
||||||
Some(
|
let workspace_root = self
|
||||||
self.project()
|
.project()
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.worktree_for_id(project_path.worktree_id, cx)?
|
.worktree_for_id(project_path.worktree_id, cx)?
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.abs_path()
|
.abs_path();
|
||||||
.to_path_buf(),
|
let project_path = project_path.path.as_ref();
|
||||||
)
|
|
||||||
|
Some(if project_path == Path::new("") {
|
||||||
|
workspace_root.to_path_buf()
|
||||||
|
} else {
|
||||||
|
workspace_root.join(project_path)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_folder_to_project(&mut self, _: &AddFolderToProject, cx: &mut ViewContext<Self>) {
|
fn add_folder_to_project(&mut self, _: &AddFolderToProject, cx: &mut ViewContext<Self>) {
|
||||||
|
@ -1661,23 +1666,14 @@ impl Workspace {
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
let project_path = path.into();
|
let task = self.load_path(path.into(), cx);
|
||||||
let task = self.load_path(project_path.clone(), cx);
|
|
||||||
cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
let (project_entry_id, build_item) = task.await?;
|
let (project_entry_id, build_item) = task.await?;
|
||||||
let pane = pane
|
let pane = pane
|
||||||
.upgrade(&cx)
|
.upgrade(&cx)
|
||||||
.ok_or_else(|| anyhow!("pane was closed"))?;
|
.ok_or_else(|| anyhow!("pane was closed"))?;
|
||||||
this.update(&mut cx, |this, cx| {
|
this.update(&mut cx, |this, cx| {
|
||||||
Pane::open_item(
|
Pane::open_item(this, pane, project_entry_id, focus_item, cx, build_item)
|
||||||
this,
|
|
||||||
pane,
|
|
||||||
project_entry_id,
|
|
||||||
&project_path,
|
|
||||||
focus_item,
|
|
||||||
cx,
|
|
||||||
build_item,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue