Fix relative path opening from project symbols
Co-Authored-By: Max <max@zed.dev>
This commit is contained in:
parent
604fcd8f1d
commit
71149bc7cc
5 changed files with 27 additions and 20 deletions
|
@ -4732,7 +4732,8 @@ impl Project {
|
|||
} else {
|
||||
return Task::ready(Err(anyhow!("worktree not found for symbol")));
|
||||
};
|
||||
let symbol_abs_path = worktree_abs_path.join(&symbol.path.path);
|
||||
|
||||
let symbol_abs_path = resolve_path(worktree_abs_path, &symbol.path.path);
|
||||
let symbol_uri = if let Ok(uri) = lsp::Url::from_file_path(symbol_abs_path) {
|
||||
uri
|
||||
} else {
|
||||
|
@ -8725,6 +8726,20 @@ fn relativize_path(base: &Path, path: &Path) -> PathBuf {
|
|||
components.iter().map(|c| c.as_os_str()).collect()
|
||||
}
|
||||
|
||||
fn resolve_path(base: &Path, path: &Path) -> PathBuf {
|
||||
let mut result = base.to_path_buf();
|
||||
for component in path.components() {
|
||||
match component {
|
||||
Component::ParentDir => {
|
||||
result.pop();
|
||||
}
|
||||
Component::CurDir => (),
|
||||
_ => result.push(component),
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
impl Item for Buffer {
|
||||
fn entry_id(&self, cx: &AppContext) -> Option<ProjectEntryId> {
|
||||
File::from_dyn(self.file()).and_then(|file| file.project_entry_id(cx))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue