(path: &str)
| 43 | } |
| 44 | |
| 45 | pub fn from_path(path: &str) -> Result<Self> { |
| 46 | let content = std::fs::read_to_string(path) |
| 47 | .with_context(|| format!("Failed to read file: {path}"))?; |
| 48 | let lang = Lang::from_path(path); |
| 49 | Ok(Self { |
| 50 | path: Some(path.to_string()), |
| 51 | buffer: EditorBuffer::from_str(&content), |
| 52 | modified: false, |
| 53 | lsp_version: 1, |
| 54 | lang, |
| 55 | scroll_top: 0, |
| 56 | }) |
| 57 | } |
| 58 | |
| 59 | pub fn save(&mut self) -> Result<()> { |
| 60 | let path = self |