Omit outlines from the outline panel, not related to the buffer's main language (#32987)

Closes https://github.com/zed-industries/zed/issues/15122

Release Notes:

- Fixed outline panel showing extra languages' outlines
This commit is contained in:
Kirill Bulatov 2025-06-19 01:36:00 +03:00 committed by GitHub
parent c34b24b5fb
commit cec19aec7b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3233,15 +3233,22 @@ impl OutlinePanel {
self.outline_fetch_tasks.insert(
(buffer_id, excerpt_id),
cx.spawn_in(window, async move |outline_panel, cx| {
let buffer_language = buffer_snapshot.language().cloned();
let fetched_outlines = cx
.background_spawn(async move {
buffer_snapshot
let mut outlines = buffer_snapshot
.outline_items_containing(
excerpt_range.context,
false,
Some(&syntax_theme),
)
.unwrap_or_default()
.unwrap_or_default();
outlines.retain(|outline| {
buffer_language.is_none()
|| buffer_language.as_ref()
== buffer_snapshot.language_at(outline.range.start)
});
outlines
})
.await;
outline_panel