mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Remove some TextUnit->usize escapees
This commit is contained in:
parent
2f9f409538
commit
88c944f96b
7 changed files with 31 additions and 27 deletions
|
@ -63,12 +63,12 @@ impl TextEdit {
|
|||
}
|
||||
|
||||
pub fn apply(&self, text: &str) -> String {
|
||||
let mut total_len = text.len();
|
||||
let mut total_len = TextUnit::of_str(text);
|
||||
for atom in self.atoms.iter() {
|
||||
total_len += atom.insert.len();
|
||||
total_len -= (atom.delete.end() - atom.delete.start()).to_usize();
|
||||
total_len += TextUnit::of_str(&atom.insert);
|
||||
total_len -= atom.delete.end() - atom.delete.start();
|
||||
}
|
||||
let mut buf = String::with_capacity(total_len);
|
||||
let mut buf = String::with_capacity(total_len.to_usize());
|
||||
let mut prev = 0;
|
||||
for atom in self.atoms.iter() {
|
||||
let start = atom.delete.start().to_usize();
|
||||
|
@ -80,7 +80,7 @@ impl TextEdit {
|
|||
prev = end;
|
||||
}
|
||||
buf.push_str(&text[prev..text.len()]);
|
||||
assert_eq!(buf.len(), total_len);
|
||||
assert_eq!(TextUnit::of_str(&buf), total_len);
|
||||
buf
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue