Only discard command comment if prev token was comment (#3628)

This fixes issues where a file with multiple def commands with their own
doc comments, some of the comments would be discarded.
This commit is contained in:
Niklas Jonsson
2021-06-17 04:11:05 +02:00
committed by GitHub
parent 631b067281
commit a59414203f
3 changed files with 163 additions and 5 deletions

View File

@ -23,3 +23,44 @@ fn defs_contain_comment_in_help() {
assert!(actual.out.contains("I comment and test. I am a good boy."));
});
}
#[test]
fn defs_contain_multiple_comments_in_help() {
Playground::setup("comment_test_2", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContent(
"my_def.nu",
r#"
# I comment and test. I am a good boy.
def comment_philosphy [] {
echo Its not a bug its an undocumented feature. (Anonymous)
}
# I comment and test all my functions. I am a very good boy.
def comment_philosphy_2 [] {
echo Its not a bug its an undocumented feature. (Anonymous)
}
# I comment and test all my functions. I am the best boy.
def comment_philosphy_3 [] {
echo Its not a bug its an undocumented feature. (Anonymous)
}
"#,
)]);
let actual = nu!(cwd: dirs.test(), r#"
source my_def.nu
help comment_philosphy
help comment_philosphy_2
help comment_philosphy_3
"#);
assert!(actual.out.contains("I comment and test. I am a good boy."));
assert!(actual
.out
.contains("I comment and test all my functions. I am a very good boy."));
assert!(actual
.out
.contains("I comment and test all my functions. I am the best boy."));
});
}