Skip to content

Commit

Permalink
Fix bug with offset
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomocavalieri authored and lpil committed Jun 5, 2024
1 parent e2f39db commit 64924b9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions compiler-core/src/language_server/tests/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ fn apply_code_edit(
panic!("Unknown url {}", change_url)
}
for edit in change {
let start = line_numbers.byte_index(edit.range.start.line, edit.range.start.character)
as i32
- offset;
let end = line_numbers.byte_index(edit.range.end.line, edit.range.end.character) as i32
- offset;
let start =
line_numbers.byte_index(edit.range.start.line, edit.range.start.character) - offset;
let end =
line_numbers.byte_index(edit.range.end.line, edit.range.end.character) - offset;
let range = (start as usize)..(end as usize);
offset += end - start - edit.new_text.len() as i32;
offset += end - start;
offset -= edit.new_text.len() as u32;
result.replace_range(range, &edit.new_text);
}
}
Expand Down

0 comments on commit 64924b9

Please sign in to comment.