Fix boundary condition where injection was not found after an edit

Max Brunsfeld created

Change summary

crates/language/src/syntax_map.rs | 33 ++++++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)

Detailed changes

crates/language/src/syntax_map.rs 🔗

@@ -984,7 +984,7 @@ fn get_injections(
     }
 
     for query_range in changed_ranges {
-        query_cursor.set_byte_range(query_range.start.saturating_sub(1)..query_range.end);
+        query_cursor.set_byte_range(query_range.start.saturating_sub(1)..query_range.end + 1);
         for mat in query_cursor.matches(&config.query, node, TextProvider(text.as_rope())) {
             let content_ranges = mat
                 .nodes_for_capture_index(config.content_capture_ix)
@@ -1888,6 +1888,37 @@ mod tests {
         );
     }
 
+    #[gpui::test]
+    fn test_combined_injections_edit_edges_of_ranges() {
+        let (buffer, syntax_map) = test_edit_sequence(
+            "ERB",
+            &[
+                "
+                    <%= one @two %>
+                    <%= three @four %>
+                ",
+                "
+                    <%= one @two %ˇ
+                    <%= three @four %>
+                ",
+                "
+                    <%= one @two %«>»
+                    <%= three @four %>
+                ",
+            ],
+        );
+
+        assert_capture_ranges(
+            &syntax_map,
+            &buffer,
+            &["tag", "ivar"],
+            "
+                <%= one «@two» %>
+                <%= three «@four» %>
+            ",
+        );
+    }
+
     #[gpui::test(iterations = 50)]
     fn test_random_syntax_map_edits(mut rng: StdRng) {
         let operations = env::var("OPERATIONS")