@@ -260,7 +260,7 @@ impl Document {
260 let line_ending = auto_detect_line_ending(&doc).unwrap_or(DEFAULT_LINE_ENDING);
260 let line_ending = auto_detect_line_ending(&doc).unwrap_or(DEFAULT_LINE_ENDING);
262 // add missing newline at the end of file
262 // add missing newline at the end of file
263− if doc.len_bytes() == 0 || char_is_line_ending(doc.char(doc.len_chars() - 1)) {
263+ if doc.len_bytes() == 0 || !char_is_line_ending(doc.char(doc.len_chars() - 1)) {
264 doc.insert(doc.len_chars(), line_ending.as_str());
264 doc.insert(doc.len_chars(), line_ending.as_str());