Fixed line-ending detection.

This commit is contained in:
Nathan Vegdahl 2017-12-31 01:04:33 -08:00
parent eb47c4844b
commit ca948588e6

View File

@ -98,10 +98,16 @@ impl<T: LineFormatter> Editor<T> {
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 {