aboutsummaryrefslogtreecommitdiff
path: root/helix-view
diff options
context:
space:
mode:
authorDimitar Gyurov2023-03-10 22:42:42 +0000
committerGitHub2023-03-10 22:42:42 +0000
commit1661e4b5e1d8ebfef28f798fcb86ba2656373ba0 (patch)
tree1c3d36d81a8fe5fafd66b6b61bc5253883ed1516 /helix-view
parent98415f288ffa043520b0c85bc4464dc44b85f948 (diff)
Add a version-control statusline element (#5682)
Diffstat (limited to 'helix-view')
-rw-r--r--helix-view/src/document.rs16
-rw-r--r--helix-view/src/editor.rs4
2 files changed, 20 insertions, 0 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index db12fb92..b2a9ddec 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -1,5 +1,6 @@
use anyhow::{anyhow, bail, Context, Error};
use arc_swap::access::DynAccess;
+use arc_swap::ArcSwap;
use futures_util::future::BoxFuture;
use futures_util::FutureExt;
use helix_core::auto_pairs::AutoPairs;
@@ -158,6 +159,7 @@ pub struct Document {
language_server: Option<Arc<helix_lsp::Client>>,
diff_handle: Option<DiffHandle>,
+ version_control_head: Option<Arc<ArcSwap<Box<str>>>>,
}
use std::{fmt, mem};
@@ -404,6 +406,7 @@ impl Document {
language_server: None,
diff_handle: None,
config,
+ version_control_head: None,
}
}
pub fn default(config: Arc<dyn DynAccess<Config>>) -> Self {
@@ -707,6 +710,8 @@ impl Document {
None => self.diff_handle = None,
}
+ self.version_control_head = provider_registry.get_current_head_name(&path);
+
Ok(())
}
@@ -1158,6 +1163,17 @@ impl Document {
}
}
+ pub fn version_control_head(&self) -> Option<Arc<Box<str>>> {
+ self.version_control_head.as_ref().map(|a| a.load_full())
+ }
+
+ pub fn set_version_control_head(
+ &mut self,
+ version_control_head: Option<Arc<ArcSwap<Box<str>>>>,
+ ) {
+ self.version_control_head = version_control_head;
+ }
+
#[inline]
/// Tree-sitter AST tree
pub fn syntax(&self) -> Option<&Syntax> {
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 1b4664ff..41aa707f 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -467,6 +467,9 @@ pub enum StatusLineElement {
/// A single space
Spacer,
+
+ /// Current version control information
+ VersionControl,
}
// Cursor shape is read and used on every rendered frame and so needs
@@ -1297,6 +1300,7 @@ impl Editor {
if let Some(diff_base) = self.diff_providers.get_diff_base(&path) {
doc.set_diff_base(diff_base, self.redraw_handle.clone());
}
+ doc.set_version_control_head(self.diff_providers.get_current_head_name(&path));
let id = self.new_document(doc);
let _ = self.launch_language_server(id);