Skip to content

Commit 3510c24

Browse files
committed
fixed bug where last line in a file whoudnt get used for bottom
1 parent b69ebac commit 3510c24

File tree

1 file changed

+3
-4
lines changed
  • git-function-history-lib/src

1 file changed

+3
-4
lines changed

git-function-history-lib/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,7 @@ fn get_stuff<T: AstNode>(
439439
let mut content: String = file[*start..found_start_brace].to_string();
440440
if &content[..1] == "\n" {
441441
content = content[1..].to_string();
442-
}
443-
(
442+
} (
444443
(start_line, end_line),
445444
(
446445
content
@@ -455,7 +454,7 @@ fn get_stuff<T: AstNode>(
455454
format!(
456455
"\n{}: {}",
457456
end_line,
458-
file.lines().nth(end_line - 1).unwrap_or("")
457+
file.lines().nth(if end_line == file.lines().count()-1 {end_line} else {end_line - 1}).unwrap_or("")
459458
),
460459
),
461460
(starts, end_line),
@@ -619,7 +618,7 @@ mod tests {
619618
Ok(functions) => {
620619
println!("{:?}", functions);
621620
}
622-
Err(e) => println!("{}", e),
621+
Err(e) => println!("-{}-", e),
623622
}
624623
assert!(output.is_ok());
625624
}

0 commit comments

Comments
 (0)