Skip to content

Commit

Permalink
fzf: add Debug impls to FzfV1, FzfV2, FzfParser
Browse files Browse the repository at this point in the history
  • Loading branch information
noib3 committed Nov 5, 2023
1 parent f0a448d commit 6f2bdac
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/algos/fzf/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ impl Default for FzfParser {
}
}

impl core::fmt::Debug for FzfParser {
#[inline]
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("FzfParser").finish_non_exhaustive()
}
}

impl FzfParser {
/// TODO: docs
#[inline]
Expand Down
16 changes: 16 additions & 0 deletions src/algos/fzf/scheme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ impl FzfScheme {
Self::History => HISTORY,
}
}

/// TODO: docs
#[inline]
pub(super) fn from_inner(scheme: &Scheme) -> Option<Self> {
if scheme.bonus_boundary_white == DEFAULT.bonus_boundary_white {
Some(Self::Default)
} else if scheme.bonus_boundary_white == PATH.bonus_boundary_white {
if scheme.initial_char_class == CharClass::Delimiter {
Some(Self::Path)
} else {
Some(Self::History)
}
} else {
None
}
}
}

/// TODO: docs
Expand Down
11 changes: 11 additions & 0 deletions src/algos/fzf/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ pub struct FzfV1 {
with_matched_ranges: bool,
}

impl core::fmt::Debug for FzfV1 {
#[inline]
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("FzfV2")
.field("case_sensitivity", &self.case_sensitivity)
.field("matched_ranges", &self.with_matched_ranges)
.field("scheme", &FzfScheme::from_inner(&self.scheme).unwrap())
.finish_non_exhaustive()
}
}

impl FzfV1 {
/// TODO: docs
#[inline]
Expand Down
11 changes: 11 additions & 0 deletions src/algos/fzf/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ pub struct FzfV2 {
with_matched_ranges: bool,
}

impl core::fmt::Debug for FzfV2 {
#[inline]
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_struct("FzfV2")
.field("case_sensitivity", &self.case_sensitivity)
.field("matched_ranges", &self.with_matched_ranges)
.field("scheme", &FzfScheme::from_inner(&self.scheme).unwrap())
.finish_non_exhaustive()
}
}

impl FzfV2 {
/// TODO: docs
#[inline]
Expand Down

0 comments on commit 6f2bdac

Please sign in to comment.