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
|
||||
Self::Comment(_) => 0,
|
||||
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::Execute(ex) => ex.get_count(options),
|
||||
Self::Group(_) => 1,
|
||||
|
|
|
@ -51,12 +51,12 @@ impl MacroString {
|
|||
#[must_use]
|
||||
pub fn line_count(&self) -> usize {
|
||||
match self {
|
||||
Self::String(s) => s.lines().count(),
|
||||
Self::String(s) => s.split('\n').count(),
|
||||
Self::MacroString(parts) => {
|
||||
parts
|
||||
.iter()
|
||||
.map(|p| match p {
|
||||
MacroStringPart::String(s) => s.lines().count() - 1,
|
||||
MacroStringPart::String(s) => s.split('\n').count() - 1,
|
||||
MacroStringPart::MacroUsage(_) => 0,
|
||||
})
|
||||
.sum::<usize>()
|
||||
|
|
Loading…
Reference in New Issue