Fix channel notes searching in buffer picker (#29611)

Previously they all used the name "Channels" for searching, now it uses
the actual content of the channel name and status.

Release Notes:

- N/A
This commit is contained in:
Julia Ryan 2025-04-29 10:57:39 -07:00 committed by GitHub
parent fd17f2d8ae
commit f7f44bfbed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -393,6 +393,23 @@ impl ChannelView {
buffer.acknowledge_buffer_version(cx); buffer.acknowledge_buffer_version(cx);
}); });
} }
fn get_channel(&self, cx: &App) -> (SharedString, Option<SharedString>) {
if let Some(channel) = self.channel(cx) {
let status = match (
self.channel_buffer.read(cx).buffer().read(cx).read_only(),
self.channel_buffer.read(cx).is_connected(),
) {
(false, true) => None,
(true, true) => Some("read-only"),
(_, false) => Some("disconnected"),
};
(channel.name.clone(), status.map(Into::into))
} else {
("<unknown>".into(), Some("disconnected".into()))
}
}
} }
impl EventEmitter<EditorEvent> for ChannelView {} impl EventEmitter<EditorEvent> for ChannelView {}
@ -440,26 +457,21 @@ impl Item for ChannelView {
Some(Icon::new(icon)) Some(Icon::new(icon))
} }
fn tab_content(&self, params: TabContentParams, _: &Window, cx: &App) -> gpui::AnyElement { fn tab_content_text(&self, _detail: usize, cx: &App) -> SharedString {
let (channel_name, status) = if let Some(channel) = self.channel(cx) { let (name, status) = self.get_channel(cx);
let status = match ( if let Some(status) = status {
self.channel_buffer.read(cx).buffer().read(cx).read_only(), format!("{name} - {status}").into()
self.channel_buffer.read(cx).is_connected(),
) {
(false, true) => None,
(true, true) => Some("read-only"),
(_, false) => Some("disconnected"),
};
(channel.name.clone(), status)
} else { } else {
("<unknown>".into(), Some("disconnected")) name
}; }
}
fn tab_content(&self, params: TabContentParams, _: &Window, cx: &App) -> gpui::AnyElement {
let (name, status) = self.get_channel(cx);
h_flex() h_flex()
.gap_2() .gap_2()
.child( .child(
Label::new(channel_name) Label::new(name)
.color(params.text_color()) .color(params.text_color())
.when(params.preview, |this| this.italic()), .when(params.preview, |this| this.italic()),
) )
@ -540,10 +552,6 @@ impl Item for ChannelView {
fn to_item_events(event: &EditorEvent, f: impl FnMut(ItemEvent)) { fn to_item_events(event: &EditorEvent, f: impl FnMut(ItemEvent)) {
Editor::to_item_events(event, f) Editor::to_item_events(event, f)
} }
fn tab_content_text(&self, _detail: usize, _cx: &App) -> SharedString {
"Channels".into()
}
} }
impl FollowableItem for ChannelView { impl FollowableItem for ChannelView {