aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/selection.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-06-21 16:59:02 +0000
committerGitHub2022-06-21 16:59:02 +0000
commit19dccade7c44619bfa414a711fe72a612e4ca358 (patch)
treed0a502bc095c1619cfb94236782f42d595af0197 /helix-core/src/selection.rs
parenta17626a822b36d4de3146c2d410f976e19dd189c (diff)
parent458b89e21dcf76bbf9ca6ba237bd334f4922722d (diff)
Merge pull request #2359 from dead10ck/test-harness
Integration testing harness
Diffstat (limited to 'helix-core/src/selection.rs')
-rw-r--r--helix-core/src/selection.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/helix-core/src/selection.rs b/helix-core/src/selection.rs
index 1b2416f5..83bab5e3 100644
--- a/helix-core/src/selection.rs
+++ b/helix-core/src/selection.rs
@@ -8,7 +8,7 @@ use crate::{
prev_grapheme_boundary,
},
movement::Direction,
- Assoc, ChangeSet, RopeSlice,
+ Assoc, ChangeSet, RopeGraphemes, RopeSlice,
};
use smallvec::{smallvec, SmallVec};
use std::borrow::Cow;
@@ -339,6 +339,14 @@ impl Range {
pub fn cursor_line(&self, text: RopeSlice) -> usize {
text.char_to_line(self.cursor(text))
}
+
+ /// Returns true if this Range covers a single grapheme in the given text
+ pub fn is_single_grapheme(&self, doc: RopeSlice) -> bool {
+ let mut graphemes = RopeGraphemes::new(doc.slice(self.from()..self.to()));
+ let first = graphemes.next();
+ let second = graphemes.next();
+ first.is_some() && second.is_none()
+ }
}
impl From<(usize, usize)> for Range {