aboutsummaryrefslogtreecommitdiff
path: root/helix-vcs/src/lib.rs
diff options
context:
space:
mode:
authorDimitar Gyurov2023-03-10 22:42:42 +0000
committerGitHub2023-03-10 22:42:42 +0000
commit1661e4b5e1d8ebfef28f798fcb86ba2656373ba0 (patch)
tree1c3d36d81a8fe5fafd66b6b61bc5253883ed1516 /helix-vcs/src/lib.rs
parent98415f288ffa043520b0c85bc4464dc44b85f948 (diff)
Add a version-control statusline element (#5682)
Diffstat (limited to 'helix-vcs/src/lib.rs')
-rw-r--r--helix-vcs/src/lib.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/helix-vcs/src/lib.rs b/helix-vcs/src/lib.rs
index 97320d32..6f5e40d0 100644
--- a/helix-vcs/src/lib.rs
+++ b/helix-vcs/src/lib.rs
@@ -1,4 +1,5 @@
-use std::path::Path;
+use arc_swap::ArcSwap;
+use std::{path::Path, sync::Arc};
#[cfg(feature = "git")]
pub use git::Git;
@@ -18,6 +19,7 @@ pub trait DiffProvider {
/// The data is returned as raw byte without any decoding or encoding performed
/// to ensure all file encodings are handled correctly.
fn get_diff_base(&self, file: &Path) -> Option<Vec<u8>>;
+ fn get_current_head_name(&self, file: &Path) -> Option<Arc<ArcSwap<Box<str>>>>;
}
#[doc(hidden)]
@@ -26,6 +28,10 @@ impl DiffProvider for Dummy {
fn get_diff_base(&self, _file: &Path) -> Option<Vec<u8>> {
None
}
+
+ fn get_current_head_name(&self, _file: &Path) -> Option<Arc<ArcSwap<Box<str>>>> {
+ None
+ }
}
pub struct DiffProviderRegistry {
@@ -38,6 +44,12 @@ impl DiffProviderRegistry {
.iter()
.find_map(|provider| provider.get_diff_base(file))
}
+
+ pub fn get_current_head_name(&self, file: &Path) -> Option<Arc<ArcSwap<Box<str>>>> {
+ self.providers
+ .iter()
+ .find_map(|provider| provider.get_current_head_name(file))
+ }
}
impl Default for DiffProviderRegistry {