Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Avoid spurious notifies in chat channel select

Max Brunsfeld84c4db13fb52
diff --git a/crates/gpui/src/views/select.rs b/crates/gpui/src/views/select.rs
index bad65ccfc8e..b1ea201fdfc 100644
--- a/crates/gpui/src/views/select.rs
+++ b/crates/gpui/src/views/select.rs
@@ -53,8 +53,10 @@ impl Select {
}
pub fn set_item_count(&mut self, count: usize, cx: &mut ViewContext<Self>) {
- self.item_count = count;
- cx.notify();
+ if count != self.item_count {
+ self.item_count = count;
+ cx.notify();
+ }
}
fn toggle(&mut self, cx: &mut ViewContext<Self>) {
@@ -63,9 +65,11 @@ impl Select {
}
pub fn set_selected_index(&mut self, ix: usize, cx: &mut ViewContext<Self>) {
- self.selected_item_ix = ix;
- self.is_open = false;
- cx.notify();
+ if ix != self.selected_item_ix || self.is_open {
+ self.selected_item_ix = ix;
+ self.is_open = false;
+ cx.notify();
+ }
}
pub fn selected_index(&self) -> usize {