Improve path display/functionality for resource links
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com> Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
This commit is contained in:
parent
e7abe34581
commit
65b1547056
2 changed files with 21 additions and 4 deletions
|
@ -168,10 +168,9 @@ fn search_paths(glob: &str, project: Entity<Project>, cx: &mut App) -> Task<Resu
|
|||
Ok(snapshots
|
||||
.iter()
|
||||
.flat_map(|snapshot| {
|
||||
let root_name = PathBuf::from(snapshot.root_name());
|
||||
snapshot
|
||||
.entries(false, 0)
|
||||
.map(move |entry| root_name.join(&entry.path))
|
||||
.map(move |entry| snapshot.abs_path().join(&entry.path))
|
||||
.filter(|path| path_matcher.is_match(&path))
|
||||
})
|
||||
.collect())
|
||||
|
|
|
@ -35,6 +35,7 @@ use prompt_store::{PromptId, PromptStore};
|
|||
use rope::Point;
|
||||
use settings::{Settings as _, SettingsStore};
|
||||
use std::cell::Cell;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use std::time::Instant;
|
||||
use std::{collections::BTreeMap, rc::Rc, time::Duration};
|
||||
|
@ -2042,8 +2043,25 @@ impl AcpThreadView {
|
|||
let uri: SharedString = resource_link.uri.clone().into();
|
||||
let is_file = resource_link.uri.strip_prefix("file://");
|
||||
|
||||
let label: SharedString = if let Some(path) = is_file {
|
||||
path.to_string().into()
|
||||
let label: SharedString = if let Some(abs_path) = is_file {
|
||||
if let Some(project_path) = self
|
||||
.project
|
||||
.read(cx)
|
||||
.project_path_for_absolute_path(&Path::new(abs_path), cx)
|
||||
&& let Some(worktree) = self
|
||||
.project
|
||||
.read(cx)
|
||||
.worktree_for_id(project_path.worktree_id, cx)
|
||||
{
|
||||
worktree
|
||||
.read(cx)
|
||||
.full_path(&project_path.path)
|
||||
.to_string_lossy()
|
||||
.to_string()
|
||||
.into()
|
||||
} else {
|
||||
abs_path.to_string().into()
|
||||
}
|
||||
} else {
|
||||
uri.clone()
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue