aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/syntax.rs
diff options
context:
space:
mode:
authorNathan Vegdahl2021-06-20 22:09:10 +0000
committerNathan Vegdahl2021-06-20 22:33:02 +0000
commit4efd6713c5b30b33c497a1f85b77a7b0a7fd17e0 (patch)
tree7661f09f2279a3f9ae6a8f76770a69fd08f95981 /helix-core/src/syntax.rs
parent5d22e3c4e574eb24260966de7f20f582e6184e24 (diff)
Work on moving code over to LineEnding instead of assuming '\n'.
Also some general cleanup and some minor fixes along the way.
Diffstat (limited to 'helix-core/src/syntax.rs')
-rw-r--r--helix-core/src/syntax.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index ae058eb1..92e52d73 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -1,4 +1,4 @@
-use crate::{regex::Regex, Change, Rope, RopeSlice, Transaction};
+use crate::{chars::char_is_line_ending, regex::Regex, Change, Rope, RopeSlice, Transaction};
pub use helix_syntax::{get_language, get_language_name, Lang};
use std::{
@@ -579,9 +579,10 @@ impl LanguageLayer {
mut column,
} = point;
- // TODO: there should be a better way here
- for ch in text.bytes() {
- if ch == b'\n' {
+ // TODO: there should be a better way here.
+ let mut chars = text.chars().peekable();
+ while let Some(ch) = chars.next() {
+ if char_is_line_ending(ch) && !(ch == '\r' && chars.peek() == Some(&'\n')) {
row += 1;
column = 0;
} else {