Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
edit_prediction: Skip type definition lookup for intrinsic TSX/JSX tags (#54666)
Gaauwe Romboutsf85cf72a4d59
diff --git a/crates/edit_prediction_context/src/edit_prediction_context.rs b/crates/edit_prediction_context/src/edit_prediction_context.rsindex 261d3383d0a..1858c87c744 100644--- a/crates/edit_prediction_context/src/edit_prediction_context.rs+++ b/crates/edit_prediction_context/src/edit_prediction_context.rs@@ -563,7 +563,7 @@ impl RelatedBuffer {}).collect::<Vec<_>>();self.cached_file = Some(CachedRelatedFile {- excerpts: excerpts,+ excerpts,buffer_version: buffer.version().clone(),});self.cached_file.as_ref().unwrap()@@ -669,6 +669,7 @@ fn identifiers_for_position(if let Some(config) = config&& config.identifier_capture_indices.contains(&capture.index)&& range.contains_inclusive(&node_range)+ && !is_tsx_tag(&buffer, &capture.node)&& Some(&node_range) != last_range.as_ref(){let name = buffer.text_for_range(node_range.clone()).collect();@@ -686,3 +687,39 @@ fn identifiers_for_position(identifiers}++fn is_tsx_tag(buffer: &BufferSnapshot, node: &tree_sitter::Node) -> bool {+ let Some(language_config) = buffer+ .language()+ .and_then(|l| l.config().jsx_tag_auto_close.as_ref())+ else {+ return false;+ };+ let Some(parent_kind) = node.parent().map(|n| n.kind()) else {+ return false;+ };++ if parent_kind != &language_config.open_tag_node_name+ && parent_kind != &language_config.close_tag_node_name+ && parent_kind != &language_config.tag_name_node_name+ && language_config+ .erroneous_close_tag_name_node_name+ .as_ref()+ .is_some_and(|kind| parent_kind != kind)+ && language_config+ .erroneous_close_tag_node_name+ .as_ref()+ .is_some_and(|kind| parent_kind == kind)+ && parent_kind != &language_config.jsx_element_node_name+ {+ return false;+ }+ // do fetch `<Component />`, model probably understands `<div>`, but needs info for user defined components+ if !buffer+ .text_for_range(node.byte_range())+ .all(|str| str.chars().all(|c| c.is_lowercase()))+ {+ return false;+ }+ true+}