diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2024-01-11 18:47:06 -0800 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2024-01-11 18:47:06 -0800 |
| commit | 781478d73dd3dfe42596e1dd370339ca6ad30e31 (patch) | |
| tree | b56554c9b8152ee7b3edc9c1ee89962861f97161 /src/main.rs | |
| parent | 7c66a5c1216f334bfa29bddd7e4c3a451900efbb (diff) | |
| download | editor-781478d73dd3dfe42596e1dd370339ca6ad30e31.tar.zst | |
Optimize for ASCII case in floor/ceil_grapheme.
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 0dfe335..c5ea852 100644 --- a/src/main.rs +++ b/src/main.rs @@ -75,7 +75,7 @@ fn floor_grapheme_cluster( line: &Rope, offset: usize, ) -> Result<usize, Box<dyn Error>> { - if offset == 0 || offset == line.len() { + if offset == 0 || offset == line.len() || line.byte(offset) < 128 { return Ok(offset); } let mut offset = line.floor_char_boundary(offset); @@ -101,6 +101,9 @@ fn ceil_grapheme_cluster( offset: usize, ) -> Result<usize, Box<dyn Error>> { let mut offset = line.ceil_char_boundary(offset); + if offset == line.len() || line.byte(offset) < 128 { + return Ok(offset); + } write!(stdout(), "\x1b[G")?; line.slice(0, offset).print(&mut stdout())?; let (_, target_col) = term::cursor_pos(stdin)?; |
