Fix boundary condition where injection was not found after an edit

This commit is contained in:
Max Brunsfeld 2022-11-10 17:04:40 -08:00
parent 2f5004c238
commit 9ad8731897

View file

@ -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")