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.

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

Kirill Bulatovcec19aec7b30
diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rs
index ce410c6b240..5bb771c1e9f 100644
--- a/crates/outline_panel/src/outline_panel.rs
+++ b/crates/outline_panel/src/outline_panel.rs
@@ -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