diff --git a/Cargo.lock b/Cargo.lock
index 78166ddc04990b2998e2a64cf831f415efd7ed61..77ccfe789f121f9358acc79507f4d6419b37ed20 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -17998,6 +17998,7 @@ name = "title_bar"
version = "0.1.0"
dependencies = [
"anyhow",
+ "arrayvec",
"auto_update",
"call",
"channel",
diff --git a/crates/csv_preview/src/renderer/table_cell.rs b/crates/csv_preview/src/renderer/table_cell.rs
index 733488110fbcdb39761b150a74c135426ca6514a..cc9690b4233c2f3b3150ff48df9e710ac7b870d2 100644
--- a/crates/csv_preview/src/renderer/table_cell.rs
+++ b/crates/csv_preview/src/renderer/table_cell.rs
@@ -39,13 +39,12 @@ fn create_table_cell(
cx: &Context<'_, CsvPreviewView>,
) -> gpui::Stateful
{
div()
- .id(ElementId::NamedInteger(
+ .id(ElementId::Name(
format!(
"csv-display-cell-{}-{}",
*display_cell_id.row, *display_cell_id.col
)
.into(),
- 0,
))
.cursor_pointer()
.flex()
diff --git a/crates/edit_prediction_context/src/edit_prediction_context.rs b/crates/edit_prediction_context/src/edit_prediction_context.rs
index a44ff8b2e3e873c23c2eaa914298a4d50aee3bdc..261d3383d0a4a4985a1b45891015bf1e1738b8a9 100644
--- a/crates/edit_prediction_context/src/edit_prediction_context.rs
+++ b/crates/edit_prediction_context/src/edit_prediction_context.rs
@@ -66,10 +66,14 @@ struct Identifier {
enum DefinitionTask {
CacheHit(Arc
),
- CacheMiss {
- definitions: Task>>>,
- type_definitions: Task>>>,
- },
+ CacheMiss(
+ Task<
+ Option<(
+ Task>>>,
+ Task>>>,
+ )>,
+ >,
+ ),
}
#[derive(Debug)]
@@ -270,39 +274,37 @@ impl RelatedExcerptStore {
let futures = this.update(cx, |this, cx| {
identifiers_with_distance
.into_iter()
- .filter_map(|(identifier, _)| {
+ .map(|(identifier, _)| {
let task = if let Some(entry) = this.cache.get(&identifier) {
DefinitionTask::CacheHit(entry.clone())
} else {
- let definitions = this
- .project
- .update(cx, |project, cx| {
- project.definitions(&buffer, identifier.range.start, cx)
- })
- .ok()?;
- let type_definitions = this
- .project
- .update(cx, |project, cx| {
- project.type_definitions(&buffer, identifier.range.start, cx)
- })
- .ok()?;
- DefinitionTask::CacheMiss {
- definitions,
- type_definitions,
- }
+ let project = this.project.clone();
+ let buffer = buffer.downgrade();
+ DefinitionTask::CacheMiss(cx.spawn(async move |_, cx| {
+ let buffer = buffer.upgrade()?;
+ let definitions = project
+ .update(cx, |project, cx| {
+ project.definitions(&buffer, identifier.range.start, cx)
+ })
+ .ok()?;
+ let type_definitions = project
+ .update(cx, |project, cx| {
+ project.type_definitions(&buffer, identifier.range.start, cx)
+ })
+ .ok()?;
+ Some((definitions, type_definitions))
+ }))
};
let cx = async_cx.clone();
let project = project.clone();
- Some(async move {
+ async move {
match task {
DefinitionTask::CacheHit(cache_entry) => {
Some((identifier, cache_entry, None))
}
- DefinitionTask::CacheMiss {
- definitions,
- type_definitions,
- } => {
+ DefinitionTask::CacheMiss(task) => {
+ let (definitions, type_definitions) = task.await?;
let (definition_locations, type_definition_locations) =
futures::join!(definitions, type_definitions);
let duration = start_time.elapsed();
@@ -349,7 +351,7 @@ impl RelatedExcerptStore {
}))
}
}
- })
+ }
})
.collect::>()
})?;
diff --git a/crates/editor/src/semantic_tokens.rs b/crates/editor/src/semantic_tokens.rs
index eaadbbb0e2ee9a49e53cc645487ea489572b1241..29c998ce976fee988e027db64ebd1f35f709f0af 100644
--- a/crates/editor/src/semantic_tokens.rs
+++ b/crates/editor/src/semantic_tokens.rs
@@ -15,7 +15,7 @@ use project::{
project_settings::ProjectSettings,
};
use settings::{
- SemanticTokenColorOverride, SemanticTokenFontStyle, SemanticTokenFontWeight,
+ SemanticTokenColorOverride, SemanticTokenFontStyle, SemanticTokenFontWeight, SemanticTokenRule,
SemanticTokenRules, Settings as _,
};
use text::BufferId;
@@ -295,13 +295,14 @@ impl Editor {
) else {
continue;
};
+ let theme = cx.theme().syntax();
token_highlights.reserve(2 * server_tokens.len());
token_highlights.extend(buffer_into_editor_highlights(
&server_tokens,
stylizer,
&multi_buffer_snapshot,
&mut interner,
- cx,
+ theme,
));
}
@@ -328,7 +329,7 @@ fn buffer_into_editor_highlights<'a, 'b>(
stylizer: &'a SemanticTokenStylizer,
multi_buffer_snapshot: &'a multi_buffer::MultiBufferSnapshot,
interner: &'b mut HighlightStyleInterner,
- cx: &'a App,
+ theme: &'a SyntaxTheme,
) -> impl Iterator- + use<'a, 'b> {
multi_buffer_snapshot
.text_anchors_to_visible_anchors(
@@ -341,12 +342,7 @@ fn buffer_into_editor_highlights<'a, 'b>(
.zip(buffer_tokens)
.filter_map(|((multi_buffer_start, multi_buffer_end), token)| {
let range = multi_buffer_start?..multi_buffer_end?;
- let style = convert_token(
- stylizer,
- cx.theme().syntax(),
- token.token_type,
- token.token_modifiers,
- )?;
+ let style = convert_token(stylizer, theme, token.token_type, token.token_modifiers)?;
let style = interner.intern(style);
Some(SemanticTokenHighlight {
range,
@@ -365,27 +361,19 @@ fn convert_token(
modifiers: u32,
) -> Option {
let rules = stylizer.rules_for_token(token_type)?;
- let matching: Vec<_> = rules
- .iter()
- .filter(|rule| {
- rule.token_modifiers
- .iter()
- .all(|m| stylizer.has_modifier(modifiers, m))
- })
- .collect();
-
- if let Some(rule) = matching.last() {
- if rule.no_style_defined() {
- return None;
- }
+ let filter = |rule: &&SemanticTokenRule| {
+ rule.token_modifiers
+ .iter()
+ .all(|m| stylizer.has_modifier(modifiers, m))
+ };
+ let last = rules.last()?;
+ if last.no_style_defined() && filter(&last) {
+ return None;
}
let mut highlight = HighlightStyle::default();
- let mut empty = true;
-
- for rule in matching {
- empty = false;
+ for rule in rules.into_iter().filter(filter) {
let style = rule
.style
.iter()
@@ -400,7 +388,7 @@ fn convert_token(
highlight.$highlight_field = rule
.$rule_field
.map($transform)
- .or_else(|| style.and_then(|s| s.$highlight_field))
+ .or_else(|| style.as_ref().and_then(|s| s.$highlight_field))
.or(highlight.$highlight_field)
};
}
@@ -460,8 +448,7 @@ fn convert_token(
},
);
}
-
- if empty { None } else { Some(highlight) }
+ Some(highlight)
}
#[cfg(test)]
diff --git a/crates/gpui/src/bounds_tree.rs b/crates/gpui/src/bounds_tree.rs
index 9cf86a2cc9b6def8fbf5ca7e94f7cd19236468cc..e95e32477b912b810607b20306be5f7d53c76df2 100644
--- a/crates/gpui/src/bounds_tree.rs
+++ b/crates/gpui/src/bounds_tree.rs
@@ -3,6 +3,7 @@ use std::{
cmp,
fmt::Debug,
ops::{Add, Sub},
+ ptr::NonNull,
};
/// Maximum children per internal node (R-tree style branching factor).
@@ -30,7 +31,7 @@ where
/// Reusable stack for tree traversal during insertion.
insert_path: Vec,
/// Reusable stack for search operations.
- search_stack: Vec,
+ search_stack: Vec>>,
}
/// A node in the bounds tree.
@@ -150,12 +151,14 @@ where
// Slow path: search the tree
self.search_stack.clear();
- self.search_stack.push(root_idx);
+ self.search_stack.push(NonNull::from(&self.nodes[root_idx]));
let mut max_found = 0u32;
- while let Some(node_idx) = self.search_stack.pop() {
- let node = &self.nodes[node_idx];
+ while let Some(node) = self.search_stack.pop() {
+ // SAFETY: `node` is guaranteed to be valid as the `nodes` stack is unmodified in this function
+ // and the `search_stack` only contains pointers from this function call.
+ let node = unsafe { node.as_ref() };
// Pruning: skip if this subtree can't improve our result
if node.max_order <= max_found {
@@ -174,11 +177,14 @@ where
NodeKind::Internal { children } => {
// Children are maintained with highest max_order at the end.
// Push in forward order to highest (last) is popped first.
- for &child_idx in children.as_slice() {
- if self.nodes[child_idx].max_order > max_found {
- self.search_stack.push(child_idx);
- }
- }
+ self.search_stack.extend(
+ children
+ .as_slice()
+ .iter()
+ .map(|&child_idx| &self.nodes[child_idx])
+ .filter(|node| node.max_order > max_found)
+ .map(NonNull::from),
+ );
}
}
}
diff --git a/crates/gpui/src/platform.rs b/crates/gpui/src/platform.rs
index 8fea468705eaf7950f41e47064e1962df2db8790..b9a3ce8e6a25cb77c80b711796704b6c37985132 100644
--- a/crates/gpui/src/platform.rs
+++ b/crates/gpui/src/platform.rs
@@ -1048,7 +1048,7 @@ impl AtlasTextureList {
}
}
-#[derive(Clone, Debug, PartialEq, Eq)]
+#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(C)]
#[expect(missing_docs)]
pub struct AtlasTile {
diff --git a/crates/gpui/src/platform/test/window.rs b/crates/gpui/src/platform/test/window.rs
index 583450c9e93e6bfdf8f45a4dcd1a83feb9b08111..ac98027b52013cb963b509f5dbbcdc29a64b44de 100644
--- a/crates/gpui/src/platform/test/window.rs
+++ b/crates/gpui/src/platform/test/window.rs
@@ -353,8 +353,8 @@ impl PlatformAtlas for TestAtlas {
>,
) -> anyhow::Result