branch list: dismiss correct window on PickerEvent.
Query proper window
This commit is contained in:
parent
806268f0db
commit
14eab4e94f
2 changed files with 9 additions and 11 deletions
|
@ -60,24 +60,24 @@ impl PickerDelegate for BranchListDelegate {
|
||||||
.read_with(&mut cx, |view, cx| {
|
.read_with(&mut cx, |view, cx| {
|
||||||
let delegate = view.delegate();
|
let delegate = view.delegate();
|
||||||
let project = delegate.workspace.read(cx).project().read(&cx);
|
let project = delegate.workspace.read(cx).project().read(&cx);
|
||||||
let mut cwd = project
|
let mut cwd =
|
||||||
|
project
|
||||||
.visible_worktrees(cx)
|
.visible_worktrees(cx)
|
||||||
.next()
|
.next()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.root_entry()
|
.abs_path()
|
||||||
.unwrap()
|
|
||||||
.path
|
|
||||||
.to_path_buf();
|
.to_path_buf();
|
||||||
cwd.push(".git");
|
cwd.push(".git");
|
||||||
let Some(repo) = project.fs().open_repo(&cwd) else {bail!("Project does not have associated git repository.")};
|
let Some(repo) = project.fs().open_repo(&cwd) else {bail!("Project does not have associated git repository.")};
|
||||||
let mut branches = repo
|
let mut branches = repo
|
||||||
.lock()
|
.lock()
|
||||||
.branches()?;
|
.branches()?;
|
||||||
if query.is_empty() {
|
|
||||||
const RECENT_BRANCHES_COUNT: usize = 10;
|
const RECENT_BRANCHES_COUNT: usize = 10;
|
||||||
|
if query.is_empty() && branches.len() > RECENT_BRANCHES_COUNT {
|
||||||
|
// Truncate list of recent branches
|
||||||
// Do a partial sort to show recent-ish branches first.
|
// Do a partial sort to show recent-ish branches first.
|
||||||
branches.select_nth_unstable_by(RECENT_BRANCHES_COUNT, |lhs, rhs| {
|
branches.select_nth_unstable_by(RECENT_BRANCHES_COUNT - 1, |lhs, rhs| {
|
||||||
rhs.unix_timestamp.cmp(&lhs.unix_timestamp)
|
rhs.unix_timestamp.cmp(&lhs.unix_timestamp)
|
||||||
});
|
});
|
||||||
branches.truncate(RECENT_BRANCHES_COUNT);
|
branches.truncate(RECENT_BRANCHES_COUNT);
|
||||||
|
@ -145,9 +145,7 @@ impl PickerDelegate for BranchListDelegate {
|
||||||
.next()
|
.next()
|
||||||
.ok_or_else(|| anyhow!("There are no visisible worktrees."))?
|
.ok_or_else(|| anyhow!("There are no visisible worktrees."))?
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.root_entry()
|
.abs_path()
|
||||||
.ok_or_else(|| anyhow!("Worktree has no root entry."))?
|
|
||||||
.path
|
|
||||||
.to_path_buf();
|
.to_path_buf();
|
||||||
cwd.push(".git");
|
cwd.push(".git");
|
||||||
let status = project
|
let status = project
|
||||||
|
|
|
@ -444,7 +444,7 @@ impl CollabTitlebarItem {
|
||||||
cx.subscribe(&view, |this, _, event, cx| {
|
cx.subscribe(&view, |this, _, event, cx| {
|
||||||
match event {
|
match event {
|
||||||
PickerEvent::Dismiss => {
|
PickerEvent::Dismiss => {
|
||||||
this.contacts_popover = None;
|
this.branch_popover = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue