mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
force comments to start with a space
This commit is contained in:
parent
c4bc98a81f
commit
1d44f7fef8
2 changed files with 25 additions and 1 deletions
|
@ -111,10 +111,16 @@ pub fn fmt_comments_only<'a, I>(
|
||||||
|
|
||||||
fn fmt_comment<'a>(buf: &mut String<'a>, comment: &'a str) {
|
fn fmt_comment<'a>(buf: &mut String<'a>, comment: &'a str) {
|
||||||
buf.push('#');
|
buf.push('#');
|
||||||
|
if !comment.starts_with(" ") {
|
||||||
|
buf.push(' ');
|
||||||
|
}
|
||||||
buf.push_str(comment);
|
buf.push_str(comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fmt_docs<'a>(buf: &mut String<'a>, docs: &'a str) {
|
fn fmt_docs<'a>(buf: &mut String<'a>, docs: &'a str) {
|
||||||
buf.push_str("##");
|
buf.push_str("##");
|
||||||
|
if !docs.starts_with(" ") {
|
||||||
|
buf.push(' ');
|
||||||
|
}
|
||||||
buf.push_str(docs);
|
buf.push_str(docs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,6 +129,24 @@ mod test_fmt {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn force_space_at_begining_of_comment() {
|
||||||
|
expr_formats_to(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
#comment
|
||||||
|
f
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
# comment
|
||||||
|
f
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn func_def() {
|
fn func_def() {
|
||||||
expr_formats_same(indoc!(
|
expr_formats_same(indoc!(
|
||||||
|
@ -704,7 +722,7 @@ mod test_fmt {
|
||||||
r#"
|
r#"
|
||||||
{
|
{
|
||||||
z: 44,
|
z: 44,
|
||||||
#comment 0
|
# comment 0
|
||||||
y: 41,
|
y: 41,
|
||||||
# comment 1
|
# comment 1
|
||||||
# comment 2
|
# comment 2
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue