fix underflow error in get_count
This commit is contained in:
parent
588bc3f464
commit
76d58c0766
|
@ -94,7 +94,7 @@ impl Command {
|
||||||
// TODO: change comment to compile to `1`, make sure nothing breaks
|
// TODO: change comment to compile to `1`, make sure nothing breaks
|
||||||
Self::Comment(_) => 0,
|
Self::Comment(_) => 0,
|
||||||
Self::Debug(_) => usize::from(options.debug),
|
Self::Debug(_) => usize::from(options.debug),
|
||||||
Self::Raw(cmd) => cmd.lines().count(),
|
Self::Raw(cmd) => cmd.split('\n').count(),
|
||||||
Self::UsesMacro(cmd) => cmd.line_count(),
|
Self::UsesMacro(cmd) => cmd.line_count(),
|
||||||
Self::Execute(ex) => ex.get_count(options),
|
Self::Execute(ex) => ex.get_count(options),
|
||||||
Self::Group(_) => 1,
|
Self::Group(_) => 1,
|
||||||
|
|
|
@ -51,12 +51,12 @@ impl MacroString {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn line_count(&self) -> usize {
|
pub fn line_count(&self) -> usize {
|
||||||
match self {
|
match self {
|
||||||
Self::String(s) => s.lines().count(),
|
Self::String(s) => s.split('\n').count(),
|
||||||
Self::MacroString(parts) => {
|
Self::MacroString(parts) => {
|
||||||
parts
|
parts
|
||||||
.iter()
|
.iter()
|
||||||
.map(|p| match p {
|
.map(|p| match p {
|
||||||
MacroStringPart::String(s) => s.lines().count() - 1,
|
MacroStringPart::String(s) => s.split('\n').count() - 1,
|
||||||
MacroStringPart::MacroUsage(_) => 0,
|
MacroStringPart::MacroUsage(_) => 0,
|
||||||
})
|
})
|
||||||
.sum::<usize>()
|
.sum::<usize>()
|
||||||
|
|
Loading…
Reference in New Issue