Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: corrected variable names #51

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/help/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct Block {
indent: usize,
margin_left: usize,
margin_right: usize,
bodys: Vec<(usize, String)>, // The vector of tuples of (first indent, text)
bodies: Vec<(usize, String)>, // The vector of tuples of (first indent, text)

_spaces: String,
}
Expand Down Expand Up @@ -94,7 +94,7 @@ impl Help {
indent: indent,
margin_left: margin_left,
margin_right: margin_right,
bodys: vec![(0, text)],
bodies: vec![(0, text)],
_spaces: " ".repeat(max_len),
};
self.blocks.push(block);
Expand Down Expand Up @@ -153,7 +153,7 @@ impl Help {
indent: indent,
margin_left: margin_left,
margin_right: margin_right,
bodys: texts.into_iter().map(|s| (0, s)).collect(),
bodies: texts.into_iter().map(|s| (0, s)).collect(),
_spaces: " ".repeat(max_len),
};
self.blocks.push(block);
Expand Down Expand Up @@ -208,10 +208,10 @@ impl Help {
margin_right: usize,
) {
let mut indent = indent;
let bodys = opts::create_opts_help(cfgs, &mut indent);
let bodies = opts::create_opts_help(cfgs, &mut indent);

let mut max_len = 0;
for (i, _) in &bodys {
for (i, _) in &bodies {
max_len = cmp::max(max_len, *i);
}

Expand All @@ -223,7 +223,7 @@ impl Help {
indent: indent,
margin_left: margin_left,
margin_right: margin_right,
bodys: bodys,
bodies: bodies,
_spaces: " ".repeat(max_len),
};
self.blocks.push(block);
Expand Down Expand Up @@ -267,7 +267,7 @@ pub struct HelpIter<'a> {
}

struct BlockIter<'a> {
bodys: &'a [(usize, String)],
bodies: &'a [(usize, String)],
index: usize,
indent: &'a str,
margin: &'a str,
Expand Down Expand Up @@ -295,14 +295,14 @@ impl Iterator for HelpIter<'_> {
impl<'a> BlockIter<'a> {
fn new(block: &'a Block, line_width: usize) -> Self {
let print_width = line_width - block.margin_left - block.margin_right;
if block.bodys.is_empty() || print_width <= block.indent {
if block.bodies.is_empty() || print_width <= block.indent {
return Self::empty();
}
let (indent, text) = &block.bodys[0];
let (indent, text) = &block.bodies[0];
let mut line_iter = linebreak::LineIter::new(&text, print_width);
line_iter.set_indent(&block._spaces[0..(*indent)]);
Self {
bodys: &block.bodys,
bodies: &block.bodies,
index: 0,
indent: &(&block._spaces)[0..block.indent],
margin: &(&block._spaces)[0..block.margin_left],
Expand All @@ -312,7 +312,7 @@ impl<'a> BlockIter<'a> {

fn empty() -> Self {
Self {
bodys: &[] as &'a [(usize, String)],
bodies: &[] as &'a [(usize, String)],
index: 0,
indent: "",
margin: "",
Expand All @@ -325,7 +325,7 @@ impl<'a> Iterator for BlockIter<'a> {
type Item = String;

fn next(&mut self) -> Option<String> {
if self.bodys.is_empty() {
if self.bodies.is_empty() {
return None;
}

Expand All @@ -337,11 +337,11 @@ impl<'a> Iterator for BlockIter<'a> {
}

self.index += 1;
if self.index >= self.bodys.len() {
if self.index >= self.bodies.len() {
break;
}

let (indent, text) = &self.bodys[self.index];
let (indent, text) = &self.bodies[self.index];
self.line_iter.init(&text);
self.line_iter.set_indent(&self.indent[0..(*indent)]);
}
Expand Down