summaryrefslogtreecommitdiff
path: root/helix-view
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-18 05:48:42 +0000
committerBlaž Hrastnik2021-03-18 05:53:29 +0000
commit8ba1e15d296fd3350332d8fa372c4c7703024a67 (patch)
tree31e7efbb2ab5a78f5521c0577f0471df77529e98 /helix-view
parent2b64f49f2c5da800ceae43359c91b9708e953d18 (diff)
Expose doc.syntax() via accessor.
Diffstat (limited to 'helix-view')
-rw-r--r--helix-view/src/document.rs12
-rw-r--r--helix-view/src/editor.rs2
2 files changed, 9 insertions, 5 deletions
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<PathBuf>,
/// Current editing mode.
pub mode: Mode,
pub restore_cursor: bool,
- /// Tree-sitter AST tree
- pub syntax: Option<Syntax>,
+ syntax: Option<Syntax>,
// /// Corresponding language scope name. Usually `source.<lang>`.
pub(crate) language: Option<Arc<LanguageConfiguration>>,
@@ -36,7 +34,6 @@ pub struct Document {
old_state: Option<State>,
/// Undo tree.
history: History,
- /// Current document version, incremented at each change.
version: i32, // should be usize?
pub diagnostics: Vec<Diagnostic>,
@@ -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()
}