mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-16 00:47:39 +03:00
breadcrumbs: Use early return in set_active_pane_item
(#14691)
This PR refactors the `set_active_pane_item` implementation for `Breadcrumbs` to use an early return to avoid indenting the method body more than necessary. Release Notes: - N/A
This commit is contained in:
parent
a2424638f5
commit
457da7b27c
@ -113,29 +113,30 @@ impl ToolbarItemView for Breadcrumbs {
|
|||||||
) -> ToolbarItemLocation {
|
) -> ToolbarItemLocation {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
self.active_item = None;
|
self.active_item = None;
|
||||||
if let Some(item) = active_pane_item {
|
|
||||||
let this = cx.view().downgrade();
|
let Some(item) = active_pane_item else {
|
||||||
self.subscription = Some(item.subscribe_to_item_events(
|
return ToolbarItemLocation::Hidden;
|
||||||
cx,
|
};
|
||||||
Box::new(move |event, cx| {
|
|
||||||
if let ItemEvent::UpdateBreadcrumbs = event {
|
let this = cx.view().downgrade();
|
||||||
this.update(cx, |this, cx| {
|
self.subscription = Some(item.subscribe_to_item_events(
|
||||||
cx.notify();
|
cx,
|
||||||
if let Some(active_item) = this.active_item.as_ref() {
|
Box::new(move |event, cx| {
|
||||||
cx.emit(ToolbarItemEvent::ChangeLocation(
|
if let ItemEvent::UpdateBreadcrumbs = event {
|
||||||
active_item.breadcrumb_location(cx),
|
this.update(cx, |this, cx| {
|
||||||
))
|
cx.notify();
|
||||||
}
|
if let Some(active_item) = this.active_item.as_ref() {
|
||||||
})
|
cx.emit(ToolbarItemEvent::ChangeLocation(
|
||||||
.ok();
|
active_item.breadcrumb_location(cx),
|
||||||
}
|
))
|
||||||
}),
|
}
|
||||||
));
|
})
|
||||||
self.active_item = Some(item.boxed_clone());
|
.ok();
|
||||||
item.breadcrumb_location(cx)
|
}
|
||||||
} else {
|
}),
|
||||||
ToolbarItemLocation::Hidden
|
));
|
||||||
}
|
self.active_item = Some(item.boxed_clone());
|
||||||
|
item.breadcrumb_location(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pane_focus_update(&mut self, pane_focused: bool, _: &mut ViewContext<Self>) {
|
fn pane_focus_update(&mut self, pane_focused: bool, _: &mut ViewContext<Self>) {
|
||||||
|
Loading…
Reference in New Issue
Block a user