diff --git a/crates/nu-command/tests/commands/use_.rs b/crates/nu-command/tests/commands/use_.rs index 543dc3df8..3e52dc133 100644 --- a/crates/nu-command/tests/commands/use_.rs +++ b/crates/nu-command/tests/commands/use_.rs @@ -32,3 +32,34 @@ fn use_module_file_within_block() { assert_eq!(actual.out, "hello world"); }) } + +#[test] +fn use_keeps_doc_comments() { + Playground::setup("use_doc_comments", |dirs, nu| { + let file = AbsolutePath::new(dirs.test().join("spam.nu")); + + nu.with_files(vec![FileWithContent( + &file.display_path(), + r#" + # this is my foo command + export def foo [ + x:string # this is an x parameter + ] { + echo "hello world" + } + "#, + )]); + + let actual = nu!( + cwd: dirs.test(), pipeline( + r#" + use spam.nu foo; + help foo + "# + ) + ); + + assert!(actual.out.contains("this is my foo command")); + assert!(actual.out.contains("this is an x parameter")); + }) +} diff --git a/crates/nu-parser/src/lex.rs b/crates/nu-parser/src/lex.rs index fb807e35d..cac85e404 100644 --- a/crates/nu-parser/src/lex.rs +++ b/crates/nu-parser/src/lex.rs @@ -276,7 +276,7 @@ pub fn lex( let mut start = curr_offset; while let Some(input) = input.get(curr_offset) { - if *input == b'\n' || *input == b'\r' { + if *input == b'\n' { if !skip_comment { output.push(Token::new( TokenContents::Comment,