@@ -1,4 +1,4 @@
1−use anyhow::Error;
1+use anyhow::{Context, Error};
2use std::future::Future;
2use std::future::Future;
3use std::path::{Path, PathBuf};
3use std::path::{Path, PathBuf};
4use std::sync::Arc;
4use std::sync::Arc;
@@ -90,7 +90,8 @@ impl Document {
90 use std::{env, fs::File, io::BufReader};
90 use std::{env, fs::File, io::BufReader};
91 let _current_dir = env::current_dir()?;
91 let _current_dir = env::current_dir()?;
93+ let file = File::open(path.clone()).context(format!("unable to open {:?}", path))?;
93− let doc = Rope::from_reader(BufReader::new(File::open(path.clone())?))?;
94+ let doc = Rope::from_reader(BufReader::new(file))?;
95 // TODO: create if not found
96 // TODO: create if not found
@@ -183,7 +184,7 @@ impl Document {
183 let success = transaction.apply(&mut self.state);
184 let success = transaction.apply(&mut self.state);
185 if !transaction.changes().is_empty() {
186 if !transaction.changes().is_empty() {
186− // TODO: self.version += 1;?
187+ self.version += 1;
188 // update tree-sitter syntax tree
189 // update tree-sitter syntax tree
189 if let Some(syntax) = &mut self.syntax {
190 if let Some(syntax) = &mut self.syntax {
@@ -193,7 +194,11 @@ impl Document {
193 .unwrap();
194 .unwrap();
197+ // if let Some(diagnostics) = &mut self.diagnostics {
198+ // for diagnostic in diagnostics {
196− // TODO: map state.diagnostics over changes::map_pos too
199+ // // TODO: map state.diagnostics over changes::map_pos too
198 // emit lsp notification
203 // emit lsp notification
199 if let Some(language_server) = &self.language_server {
204 if let Some(language_server) = &self.language_server {
@@ -230,7 +235,6 @@ impl Document {
231 pub fn undo(&mut self) -> bool {
236 pub fn undo(&mut self) -> bool {
232 if let Some(transaction) = self.history.undo() {
237 if let Some(transaction) = self.history.undo() {
234 let success = self._apply(&transaction);
238 let success = self._apply(&transaction);
236 // reset changeset to fix len
240 // reset changeset to fix len
@@ -243,8 +247,6 @@ impl Document {
244 pub fn redo(&mut self) -> bool {
248 pub fn redo(&mut self) -> bool {
245 if let Some(transaction) = self.history.redo() {
249 if let Some(transaction) = self.history.redo() {
248 let success = self._apply(&transaction);
250 let success = self._apply(&transaction);
250 // reset changeset to fix len
252 // reset changeset to fix len
@@ -266,9 +268,6 @@ impl Document {
266 // annotations either add a new layer or compose into the previous one.
268 // annotations either add a new layer or compose into the previous one.
267 let transaction = Transaction::from(changes).with_selection(self.selection().clone());
269 let transaction = Transaction::from(changes).with_selection(self.selection().clone());
269− // increment document version
272 // HAXX: we need to reconstruct the state as it was before the changes..
271 // HAXX: we need to reconstruct the state as it was before the changes..
273 let old_state = self.old_state.take().expect("no old_state available");
272 let old_state = self.old_state.take().expect("no old_state available");