Fix project panel selection related issues (#7245)
Fixes #7003 and #7005. Selecting as a reaction to actually opening a new item doesn’t seem robust in all cases, the PR improves that. Release Notes: - Fixed missing project panel file selection in certain cases
This commit is contained in:
parent
5ed3b44686
commit
8fed9aaec2
1 changed files with 15 additions and 4 deletions
|
@ -262,11 +262,14 @@ impl ProjectPanel {
|
||||||
if let Some(worktree) = project.read(cx).worktree_for_entry(entry_id, cx) {
|
if let Some(worktree) = project.read(cx).worktree_for_entry(entry_id, cx) {
|
||||||
if let Some(entry) = worktree.read(cx).entry_for_id(entry_id) {
|
if let Some(entry) = worktree.read(cx).entry_for_id(entry_id) {
|
||||||
let file_path = entry.path.clone();
|
let file_path = entry.path.clone();
|
||||||
|
let worktree_id = worktree.read(cx).id();
|
||||||
|
let entry_id = entry.id;
|
||||||
|
|
||||||
workspace
|
workspace
|
||||||
.open_path(
|
.open_path(
|
||||||
ProjectPath {
|
ProjectPath {
|
||||||
worktree_id: worktree.read(cx).id(),
|
worktree_id,
|
||||||
path: entry.path.clone(),
|
path: file_path.clone(),
|
||||||
},
|
},
|
||||||
None,
|
None,
|
||||||
focus_opened_item,
|
focus_opened_item,
|
||||||
|
@ -281,8 +284,16 @@ impl ProjectPanel {
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if !focus_opened_item {
|
|
||||||
if let Some(project_panel) = project_panel.upgrade() {
|
if let Some(project_panel) = project_panel.upgrade() {
|
||||||
|
// Always select the entry, regardless of whether it is opened or not.
|
||||||
|
project_panel.update(cx, |project_panel, _| {
|
||||||
|
project_panel.selection = Some(Selection {
|
||||||
|
worktree_id,
|
||||||
|
entry_id
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if !focus_opened_item {
|
||||||
let focus_handle = project_panel.read(cx).focus_handle.clone();
|
let focus_handle = project_panel.read(cx).focus_handle.clone();
|
||||||
cx.focus(&focus_handle);
|
cx.focus(&focus_handle);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue