@@ -1,4 +1,4 @@
1−use anyhow::Error;
1+use anyhow::{Context, Error};
22use std::future::Future;
33use std::path::{Path, PathBuf};
44use std::sync::Arc;
@@ -90,7 +90,8 @@ impl Document {
9090 use std::{env, fs::File, io::BufReader};
9191 let _current_dir = env::current_dir()?;
9292
93− let doc = Rope::from_reader(BufReader::new(File::open(path.clone())?))?;
93+ let file = File::open(path.clone()).context(format!("unable to open {:?}", path))?;
94+ let doc = Rope::from_reader(BufReader::new(file))?;
9495
9596 // TODO: create if not found
9697
@@ -183,7 +184,7 @@ impl Document {
183184 let success = transaction.apply(&mut self.state);
184185
185186 if !transaction.changes().is_empty() {
186− // TODO: self.version += 1;?
187+ self.version += 1;
187188
188189 // update tree-sitter syntax tree
189190 if let Some(syntax) = &mut self.syntax {
@@ -193,7 +194,11 @@ impl Document {
193194 .unwrap();
194195 }
195196
196− // TODO: map state.diagnostics over changes::map_pos too
197+ // if let Some(diagnostics) = &mut self.diagnostics {
198+ // for diagnostic in diagnostics {
199+ // // TODO: map state.diagnostics over changes::map_pos too
200+ // }
201+ // }
197202
198203 // emit lsp notification
199204 if let Some(language_server) = &self.language_server {
@@ -230,7 +235,6 @@ impl Document {
230235
231236 pub fn undo(&mut self) -> bool {
232237 if let Some(transaction) = self.history.undo() {
233− self.version += 1;
234238 let success = self._apply(&transaction);
235239
236240 // reset changeset to fix len
@@ -243,8 +247,6 @@ impl Document {
243247
244248 pub fn redo(&mut self) -> bool {
245249 if let Some(transaction) = self.history.redo() {
246− self.version += 1;
247−
248250 let success = self._apply(&transaction);
249251
250252 // reset changeset to fix len
@@ -266,9 +268,6 @@ impl Document {
266268 // annotations either add a new layer or compose into the previous one.
267269 let transaction = Transaction::from(changes).with_selection(self.selection().clone());
268270
269− // increment document version
270− self.version += 1;
271−
272271 // HAXX: we need to reconstruct the state as it was before the changes..
273272 let old_state = self.old_state.take().expect("no old_state available");
274273