From 977ef663568b8ce97bb0be4c5519cea546586543 Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Fri, 25 Feb 2022 13:03:39 -0500 Subject: [PATCH] Fix Windows doc comments (#4643) * WIP windows doc comments * WIP windows doc comments * WIP windows doc comments * actual fix this time --- crates/nu-command/tests/commands/use_.rs | 31 ++++++++++++++++++++++++ crates/nu-parser/src/lex.rs | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) 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,