comply with cargo format

This commit is contained in:
Gabriel Van Zandycke 2025-03-26 10:42:54 +01:00
parent 3a9e582b0f
commit 473a70c75c
2 changed files with 22 additions and 8 deletions

View file

@ -43,12 +43,27 @@ pub fn write(item: &Item) -> String {
let splitted_snippet = item.snippet.split(LINE_SEPARATOR).collect::<Vec<&str>>();
let printer_item = (0..=separator_count)
.map(|i| {format!("{tags_short}{delimiter}{comment_line_i}{delimiter}{snippet_line_i}",
tags_short = style(limit_str(if i == 0 { &item.tags } else { "" }, tag_width_percentage)).with(CONFIG.tag_color()),
comment_line_i = style(limit_str(splitted_comment.get(i).unwrap_or(&""), comment_width_percentage)).with(CONFIG.comment_color()),
snippet_line_i = style(limit_str(splitted_snippet.get(i).unwrap_or(&""), snippet_width_percentage)).with(CONFIG.snippet_color()),
delimiter = " ",
)})
.map(|i| {
format!(
"{tags_short}{delimiter}{comment_line_i}{delimiter}{snippet_line_i}",
tags_short = style(limit_str(
if i == 0 { &item.tags } else { "" },
tag_width_percentage
))
.with(CONFIG.tag_color()),
comment_line_i = style(limit_str(
splitted_comment.get(i).unwrap_or(&""),
comment_width_percentage
))
.with(CONFIG.comment_color()),
snippet_line_i = style(limit_str(
splitted_snippet.get(i).unwrap_or(&""),
snippet_width_percentage
))
.with(CONFIG.snippet_color()),
delimiter = " ",
)
})
.collect::<Vec<String>>()
.join("\n");

View file

@ -287,8 +287,7 @@ impl<'a> Parser<'a> {
should_break = self.write_cmd(&item).is_err();
item.snippet = String::from("");
item.comment = without_prefix(&line);
}
else {
} else {
if !item.comment.is_empty() {
item.comment.push_str(deser::LINE_SEPARATOR);
}