diff --git a/crates/nu-cli/tests/completions/mod.rs b/crates/nu-cli/tests/completions/mod.rs index a3eb692adf..eb245e2fb2 100644 --- a/crates/nu-cli/tests/completions/mod.rs +++ b/crates/nu-cli/tests/completions/mod.rs @@ -292,6 +292,8 @@ fn partial_completions() { // Create the expected values let expected_paths: Vec = vec![ + file(dir.join("partial_a").join("have_ext.exe")), + file(dir.join("partial_a").join("have_ext.txt")), file(dir.join("partial_a").join("hello")), file(dir.join("partial_a").join("hola")), file(dir.join("partial_b").join("hello_b")), @@ -310,6 +312,8 @@ fn partial_completions() { // Create the expected values let expected_paths: Vec = vec![ file(dir.join("partial_a").join("anotherfile")), + file(dir.join("partial_a").join("have_ext.exe")), + file(dir.join("partial_a").join("have_ext.txt")), file(dir.join("partial_a").join("hello")), file(dir.join("partial_a").join("hola")), file(dir.join("partial_b").join("hello_b")), @@ -360,6 +364,34 @@ fn partial_completions() { // Match the results match_suggestions(expected_paths, suggestions); + + // Test completion for all files under directories whose names begin with "pa" + let file_str = file(dir.join("partial_a").join("have")); + let target_file = format!("rm {file_str}"); + let suggestions = completer.complete(&target_file, target_file.len()); + + // Create the expected values + let expected_paths: Vec = vec![ + file(dir.join("partial_a").join("have_ext.exe")), + file(dir.join("partial_a").join("have_ext.txt")), + ]; + + // Match the results + match_suggestions(expected_paths, suggestions); + + // Test completion for all files under directories whose names begin with "pa" + let file_str = file(dir.join("partial_a").join("have_ext.")); + let file_dir = format!("rm {file_str}"); + let suggestions = completer.complete(&file_dir, file_dir.len()); + + // Create the expected values + let expected_paths: Vec = vec![ + file(dir.join("partial_a").join("have_ext.exe")), + file(dir.join("partial_a").join("have_ext.txt")), + ]; + + // Match the results + match_suggestions(expected_paths, suggestions); } #[test] @@ -394,6 +426,13 @@ fn command_ls_with_filecompletion() { ".hidden_folder/".to_string(), ]; + match_suggestions(expected_paths, suggestions); + + let target_dir = "ls custom_completion."; + let suggestions = completer.complete(target_dir, target_dir.len()); + + let expected_paths: Vec = vec!["custom_completion.nu".to_string()]; + match_suggestions(expected_paths, suggestions) } #[test] @@ -428,6 +467,13 @@ fn command_open_with_filecompletion() { ".hidden_folder/".to_string(), ]; + match_suggestions(expected_paths, suggestions); + + let target_dir = "open custom_completion."; + let suggestions = completer.complete(target_dir, target_dir.len()); + + let expected_paths: Vec = vec!["custom_completion.nu".to_string()]; + match_suggestions(expected_paths, suggestions) } diff --git a/tests/fixtures/partial_completions/partial_a/have_ext.exe b/tests/fixtures/partial_completions/partial_a/have_ext.exe new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/fixtures/partial_completions/partial_a/have_ext.txt b/tests/fixtures/partial_completions/partial_a/have_ext.txt new file mode 100644 index 0000000000..e69de29bb2