mirror of
https://github.com/helix-editor/helix.git
synced 2025-04-07 04:47:45 +03:00
toggling of block comments (#4718)
This commit is contained in:
parent
f46a09ab4f
commit
26b3dc29be
11 changed files with 568 additions and 29 deletions
|
@ -14,6 +14,8 @@ pub trait RopeSliceExt<'a>: Sized {
|
|||
byte_range: R,
|
||||
) -> RegexInput<RopeyCursor<'a>>;
|
||||
fn regex_input_at<R: RangeBounds<usize>>(self, char_range: R) -> RegexInput<RopeyCursor<'a>>;
|
||||
fn first_non_whitespace_char(self) -> Option<usize>;
|
||||
fn last_non_whitespace_char(self) -> Option<usize>;
|
||||
}
|
||||
|
||||
impl<'a> RopeSliceExt<'a> for RopeSlice<'a> {
|
||||
|
@ -64,4 +66,13 @@ impl<'a> RopeSliceExt<'a> for RopeSlice<'a> {
|
|||
};
|
||||
input.range(byte_range)
|
||||
}
|
||||
fn first_non_whitespace_char(self) -> Option<usize> {
|
||||
self.chars().position(|ch| !ch.is_whitespace())
|
||||
}
|
||||
fn last_non_whitespace_char(self) -> Option<usize> {
|
||||
self.chars_at(self.len_chars())
|
||||
.reversed()
|
||||
.position(|ch| !ch.is_whitespace())
|
||||
.map(|pos| self.len_chars() - pos - 1)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue