Skip to content

Commit 9b9bc72

Browse files
authored
[Fix] wrong fallback value of line number (#100)
1 parent 5a68ebb commit 9b9bc72

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

cli/src/code.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ pub fn create_code(cli: &CLI, code_config: Code) -> anyhow::Result<Content> {
2424
let parsed_code_snippet = parsed_range.cut_code_snippet(&code_snippet)?;
2525
let mut code = CodeBuilder::default()
2626
.content(parsed_code_snippet)
27-
.start_line_number(parsed_range.0 as u32)
2827
.build()?;
2928

29+
code.start_line_number = cli
30+
.has_line_number
31+
.then_some(cli.start_line_number.unwrap_or(parsed_range.0 as u32));
32+
3033
code.file_path = cli
3134
.from_file
3235
.clone()

cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct CLI {
9292

9393
/// Breadcrumbs is a useful and unique feature in CodeSnap, it shows the path of the file
9494
/// so that users can know where the code snippet comes from.
95-
#[arg(long)]
95+
#[arg(long, default_value = "false")]
9696
has_breadcrumbs: Option<bool>,
9797

9898
#[arg(long, default_value = "false")]

0 commit comments

Comments
 (0)