mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-27 12:54:42 +00:00
Fix boundary condition where injection was not found after an edit
This commit is contained in:
parent
2f5004c238
commit
9ad8731897
1 changed files with 32 additions and 1 deletions
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue