reread files from disk

This commit is contained in:
Aleksey Kladov 2018-08-28 19:42:55 +03:00
parent dea6ed73fa
commit b6c654e233

View file

@ -1,4 +1,5 @@
use std::{ use std::{
fs,
path::{PathBuf, Path}, path::{PathBuf, Path},
collections::HashMap, collections::HashMap,
}; };
@ -78,10 +79,12 @@ impl ServerWorldState {
let file_id = self.path_map.get_id(path).ok_or_else(|| { let file_id = self.path_map.get_id(path).ok_or_else(|| {
format_err!("change to unknown file: {}", path.display()) format_err!("change to unknown file: {}", path.display())
})?; })?;
let text = match self.mem_map.remove(&file_id) { match self.mem_map.remove(&file_id) {
Some(text) => text, Some(_) => (),
None => bail!("unmatched close notification"), None => bail!("unmatched close notification"),
}; };
// Do this via file watcher ideally.
let text = fs::read_to_string(path).ok();
self.analysis.change_file(file_id, text); self.analysis.change_file(file_id, text);
Ok(()) Ok(())
} }