summaryrefslogtreecommitdiffstats
path: root/src/app/selection.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2021-04-19 20:59:15 +0200
committerCanop <cano.petrole@gmail.com>2021-04-19 20:59:15 +0200
commit6da21634bf925b9e3bce497b5d8e6218786f2628 (patch)
tree00a1d150a8f8847933266791b86672a050481818 /src/app/selection.rs
parentaa1dc4a944ad1f11cf8292c49cb771dd1384c6c7 (diff)
improve command previsualization in status for multiselection
If a group is common to all paths, it will be kept
Diffstat (limited to 'src/app/selection.rs')
-rw-r--r--src/app/selection.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/app/selection.rs b/src/app/selection.rs
index 98ad2b1..07d5e1e 100644
--- a/src/app/selection.rs
+++ b/src/app/selection.rs
@@ -96,7 +96,7 @@ impl Selection<'_> {
}
}
-impl SelInfo<'_> {
+impl<'a> SelInfo<'a> {
pub fn common_path(&self) -> Option<PathBuf> {
match self {
SelInfo::None => None,
@@ -104,6 +104,13 @@ impl SelInfo<'_> {
SelInfo::More(stage) => Some(longest_common_ancestor(&stage.paths))
}
}
+ pub fn count_paths(&self) -> usize {
+ match self {
+ SelInfo::None => 0,
+ SelInfo::One(_) => 1,
+ SelInfo::More(stage) => stage.paths.len(),
+ }
+ }
pub fn common_stype(&self) -> Option<SelectionType> {
match self {
SelInfo::None => None,
@@ -118,6 +125,11 @@ impl SelInfo<'_> {
Some(stype)
}
}
-
+ }
+ pub fn as_one_sel(self) -> Option<Selection<'a>> {
+ match self {
+ SelInfo::One(sel) => Some(sel),
+ _ => None,
+ }
}
}