@@ -147,7 +147,12 @@ impl Document {
147147 Rope::from("\n")
148148 } else {
149149 let file = File::open(&path).context(format!("unable to open {:?}", path))?;
150− Rope::from_reader(BufReader::new(file))?
150+ let mut doc = Rope::from_reader(BufReader::new(file))?;
151+ // add missing newline at the end of file
152+ if doc.byte(doc.len_bytes() - 1) != b'\n' {
153+ doc.insert_char(doc.len_chars(), '\n');
154+ }
155+ doc
151156 };
152157
153158 let mut doc = Self::new(doc);