From f99d131ec3ab60956344d001bcd40244343c241b Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 21 Jun 2022 12:06:51 +0200 Subject: Add support for inferring line ending, configurable * Rename `CompileOptions` to `Options` * Add support for an optional default line ending style * Add support for inferring the used line ending style --- src/tokenizer.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/tokenizer.rs') diff --git a/src/tokenizer.rs b/src/tokenizer.rs index c0a7105..ba9bcbb 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -677,7 +677,6 @@ fn attempt_impl( } /// Turn a string into codes. -// To do: handle BOM at start? pub fn as_codes(value: &str) -> Vec { let mut codes: Vec = vec![]; let mut at_start = true; @@ -748,7 +747,10 @@ pub fn as_codes(value: &str) -> Vec { }; } - // To do: handle a final CR? + // Send the last CR: we’re not at a next `\n`. + if at_carriage_return { + codes.push(Code::Char('\r')); + } codes } -- cgit