diff --git a/justfile b/justfile index 11f47db..fa126f6 100755 --- a/justfile +++ b/justfile @@ -16,11 +16,13 @@ watch +args='test': test: cargo test -ci: build-book +ci: lint build-book cargo test --all + +lint: cargo clippy --all --all-targets -- --deny warnings - cargo fmt --all -- --check ./bin/forbid + cargo fmt --all -- --check cargo update --locked --package just fuzz: diff --git a/src/subcommand.rs b/src/subcommand.rs index 6c405b7..865b28f 100644 --- a/src/subcommand.rs +++ b/src/subcommand.rs @@ -539,13 +539,13 @@ impl Subcommand { ordered.insert(0, None); } + let no_groups = groups.contains_key(&None) && groups.len() == 1; + for (i, group) in ordered.into_iter().enumerate() { if i > 0 { println!(); } - let no_groups = groups.contains_key(&None) && groups.len() == 1; - if !no_groups { print!("{list_prefix}"); if let Some(group) = &group { @@ -605,7 +605,11 @@ impl Subcommand { Self::list_module(config, submodule, depth + 1); } } else { - for submodule in module.modules(config) { + for (i, submodule) in module.modules(config).into_iter().enumerate() { + if !no_groups && !groups.is_empty() && i == 0 { + println!(); + } + print!("{list_prefix}{} ...", submodule.name()); format_doc( config, diff --git a/tests/list.rs b/tests/list.rs index 0ed5cba..4b9d56d 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -405,3 +405,49 @@ fn module_doc_aligned() { ) .run(); } + +#[test] +fn space_before_submodules_following_groups() { + Test::new() + .write("foo.just", "") + .justfile( + " + mod foo + + [group: 'baz'] + bar: + ", + ) + .test_round_trip(false) + .args(["--unstable", "--list"]) + .stdout( + " + Available recipes: + [baz] + bar + + foo ... + ", + ) + .run(); +} + +#[test] +fn no_space_before_submodules_not_following_groups() { + Test::new() + .write("foo.just", "") + .justfile( + " + mod foo + ", + ) + .test_round_trip(false) + .args(["--unstable", "--list"]) + .stdout( + " + Available recipes: + foo ... + ", + ) + .run(); +}