Drop active searchable item subscription when changing active item
We were leaking the previous active item's subscription, which meant that we would receive the `MatchesInvalidated` event as many times as we changed items. Co-Authored-By: Thorsten Ball <thorsten@zed.dev> Co-Authored-By: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
co-authored by
Thorsten Ball
Mikayla Maki
parent
21e6b09361
commit
b151e12890
@@ -396,8 +396,8 @@ impl ToolbarItemView for BufferSearchBar {
|
||||
{
|
||||
let this = cx.view().downgrade();
|
||||
|
||||
searchable_item_handle
|
||||
.subscribe_to_search_events(
|
||||
self.active_searchable_item_subscription =
|
||||
Some(searchable_item_handle.subscribe_to_search_events(
|
||||
cx,
|
||||
Box::new(move |search_event, cx| {
|
||||
if let Some(this) = this.upgrade() {
|
||||
@@ -406,8 +406,7 @@ impl ToolbarItemView for BufferSearchBar {
|
||||
});
|
||||
}
|
||||
}),
|
||||
)
|
||||
.detach();
|
||||
));
|
||||
|
||||
self.active_searchable_item = Some(searchable_item_handle);
|
||||
let _ = self.update_matches(cx);
|
||||
|
||||
Reference in New Issue
Block a user