From 8ba1e15d296fd3350332d8fa372c4c7703024a67 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Thu, 18 Mar 2021 14:48:42 +0900 Subject: Expose doc.syntax() via accessor. --- helix-view/src/document.rs | 12 ++++++++---- helix-view/src/editor.rs | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'helix-view') diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index 6ccbfbec..76a3b8e9 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -18,15 +18,13 @@ pub enum Mode { pub struct Document { pub state: State, // rope + selection - /// File path on disk. path: Option, /// Current editing mode. pub mode: Mode, pub restore_cursor: bool, - /// Tree-sitter AST tree - pub syntax: Option, + syntax: Option, // /// Corresponding language scope name. Usually `source.`. pub(crate) language: Option>, @@ -36,7 +34,6 @@ pub struct Document { old_state: Option, /// Undo tree. history: History, - /// Current document version, incremented at each change. version: i32, // should be usize? pub diagnostics: Vec, @@ -284,6 +281,7 @@ impl Document { } #[inline] + /// Current document version, incremented at each change. pub fn version(&self) -> i32 { self.version } @@ -292,7 +290,13 @@ impl Document { self.language_server.as_deref() } + /// Tree-sitter AST tree + pub fn syntax(&self) -> Option<&Syntax> { + self.syntax.as_ref() + } + #[inline] + /// File path on disk. pub fn path(&self) -> Option<&PathBuf> { self.path.as_ref() } diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 9b32b335..3de2bfb8 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -95,7 +95,7 @@ impl Editor { self.tree.remove(id) } - pub fn should_close(&mut self) -> bool { + pub fn should_close(&self) -> bool { self.tree.is_empty() } -- cgit v1.2.3-70-g09d2