diff --git a/src/editor/mod.rs b/src/editor/mod.rs index b4e38c8..a84b36d 100644 --- a/src/editor/mod.rs +++ b/src/editor/mod.rs @@ -98,10 +98,16 @@ impl Editor { let mut line_i: usize = 0; for line in self.buffer.line_iter() { // Get the line ending - let ending = if line.len_chars() > 0 { + let ending = if line.len_chars() == 1 { let g = line.slice(line.len_chars() - 1, line.len_chars()) .graphemes() - .nth(0) + .last() + .unwrap(); + str_to_line_ending(g) + } else if line.len_chars() > 1 { + let g = line.slice(line.len_chars() - 2, line.len_chars()) + .graphemes() + .last() .unwrap(); str_to_line_ending(g) } else {