When hovering paths in terminal, search worktree entries for relative ones only (#29406)

Follow-up of https://github.com/zed-industries/zed/pull/29274

Release Notes:

- N/A
This commit is contained in:
Kirill Bulatov 2025-04-25 15:34:09 +03:00 committed by GitHub
parent 93862838bd
commit 49003d8038
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1100,7 +1100,7 @@ fn possible_open_target(
for path_with_position in &potential_paths { for path_with_position in &potential_paths {
let path_to_check = if worktree_root.ends_with(&path_with_position.path) { let path_to_check = if worktree_root.ends_with(&path_with_position.path) {
let root_path_with_posiition = PathWithPosition { let root_path_with_position = PathWithPosition {
path: worktree_root.to_path_buf(), path: worktree_root.to_path_buf(),
row: path_with_position.row, row: path_with_position.row,
column: path_with_position.column, column: path_with_position.column,
@ -1108,11 +1108,11 @@ fn possible_open_target(
match worktree.read(cx).root_entry() { match worktree.read(cx).root_entry() {
Some(root_entry) => { Some(root_entry) => {
return Task::ready(Some(OpenTarget::Worktree( return Task::ready(Some(OpenTarget::Worktree(
root_path_with_posiition, root_path_with_position,
root_entry.clone(), root_entry.clone(),
))); )));
} }
None => root_path_with_posiition, None => root_path_with_position,
} }
} else { } else {
PathWithPosition { PathWithPosition {
@ -1126,18 +1126,20 @@ fn possible_open_target(
} }
}; };
if let Some(entry) = worktree.read(cx).entry_for_path(&path_to_check.path) { if path_to_check.path.is_relative() {
return Task::ready(Some(OpenTarget::Worktree( if let Some(entry) = worktree.read(cx).entry_for_path(&path_to_check.path) {
PathWithPosition { return Task::ready(Some(OpenTarget::Worktree(
path: worktree_root.join(&entry.path), PathWithPosition {
row: path_to_check.row, path: worktree_root.join(&entry.path),
column: path_to_check.column, row: path_to_check.row,
}, column: path_to_check.column,
entry.clone(), },
))); entry.clone(),
} else { )));
paths_to_check.push(path_to_check); }
} }
paths_to_check.push(path_to_check);
} }
if !paths_to_check.is_empty() { if !paths_to_check.is_empty() {