mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Convert code to text-size
This commit is contained in:
parent
27a7718880
commit
b1d5817dd1
75 changed files with 438 additions and 456 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
mod text_edit;
|
||||
|
||||
use text_unit::{TextRange, TextUnit};
|
||||
use text_size::{TextRange, TextSize};
|
||||
|
||||
pub use crate::text_edit::{TextEdit, TextEditBuilder};
|
||||
|
||||
|
@ -23,13 +23,13 @@ impl AtomTextEdit {
|
|||
AtomTextEdit::replace(range, String::new())
|
||||
}
|
||||
|
||||
pub fn insert(offset: TextUnit, text: String) -> AtomTextEdit {
|
||||
AtomTextEdit::replace(TextRange::offset_len(offset, 0.into()), text)
|
||||
pub fn insert(offset: TextSize, text: String) -> AtomTextEdit {
|
||||
AtomTextEdit::replace(TextRange::empty(offset), text)
|
||||
}
|
||||
|
||||
pub fn apply(&self, mut text: String) -> String {
|
||||
let start = self.delete.start().to_usize();
|
||||
let end = self.delete.end().to_usize();
|
||||
let start: usize = self.delete.start().into();
|
||||
let end: usize = self.delete.end().into();
|
||||
text.replace_range(start..end, &self.insert);
|
||||
text
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue