pub struct Change<'h, S = &'h str> { /* private fields */ }Expand description
A change in a buffer, with a start, taken text, and added text.
Implementations§
Source§impl Change<'static, String>
impl Change<'static, String>
Source§impl<'h> Change<'h>
impl<'h> Change<'h>
Sourcepub fn to_string_change(&self) -> Change<'static, String>
pub fn to_string_change(&self) -> Change<'static, String>
Creates a Change<String> from a Change<&str>.
Sourcepub fn str_insert(added_str: &'h str, start: Point) -> Self
pub fn str_insert(added_str: &'h str, start: Point) -> Self
Returns a new copyable Change from an insertion.
Source§impl<'s, S: Borrow<str>> Change<'s, S>
impl<'s, S: Borrow<str>> Change<'s, S>
Sourcepub fn line_range(&self, strs: &Strs) -> Range<Point>
pub fn line_range(&self, strs: &Strs) -> Range<Point>
Gets a Range<Point>, from the start to the end of the
affected lines.
For example, if you make an edit that transforms lines 1..=3
to lines 1..=5, this function will return a Range that
starts at the beginning of line 1, and ends at the end of line
5.
§Note
This end of this range will come after the last \n,
which means that, in that example, said point would have a
Point::line value equal to 6, not 5, since it
represents both the end of line 5, and the beginning of line
6.
Sourcepub fn taken_range(&self) -> Range<Point>
pub fn taken_range(&self) -> Range<Point>
Returns the taken Range.
Sourcepub fn added_range(&self) -> Range<Point>
pub fn added_range(&self) -> Range<Point>
Returns the added Range.
Sourcepub fn taken_byte_col(&self, strs: &Strs) -> usize
pub fn taken_byte_col(&self, strs: &Strs) -> usize
The ending byte column before this Change took place.
You shouldn’t call change.end_point().byte_col(strs) because
that will calculate the byte column with the new state of the
Text, when you should be doing so with the old state.
This function does that for you.
Sourcepub fn taken_char_col(&self, strs: &Strs) -> usize
pub fn taken_char_col(&self, strs: &Strs) -> usize
The ending char column before thiss Change took place.
You shouldn’t call change.end_point().char_col(strs) because
that will calculate the byte column with the new state of the
Text, when you should be doing so with the old state.
This function does that for you.