From f609a4f26afa7d6490fcf2cbc387eff4f7c3f3f0 Mon Sep 17 00:00:00 2001 From: WindSoilder Date: Wed, 11 Jan 2023 03:41:54 +0800 Subject: [PATCH] Auto-Completion: put ` tildes around filenames with parentheses (#7712) # Description Fixes: #7706 # User-Facing Changes ![img](https://user-images.githubusercontent.com/22256154/211286663-3d07a650-5e2d-406e-99f6-cff90dba352b.png) # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. Co-authored-by: Stefan Holderbach --- crates/nu-cli/src/completions/file_completions.rs | 2 ++ crates/nu-cli/tests/completions.rs | 1 + tests/fixtures/quoted_completions/te(st).txt | 0 3 files changed, 3 insertions(+) create mode 100644 tests/fixtures/quoted_completions/te(st).txt diff --git a/crates/nu-cli/src/completions/file_completions.rs b/crates/nu-cli/src/completions/file_completions.rs index d589799d1..6ee3cf55b 100644 --- a/crates/nu-cli/src/completions/file_completions.rs +++ b/crates/nu-cli/src/completions/file_completions.rs @@ -146,6 +146,8 @@ pub fn file_path_completion( || path.contains('"') || path.contains(' ') || path.contains('#') + || path.contains('(') + || path.contains(')') { path = format!("`{}`", path); } diff --git a/crates/nu-cli/tests/completions.rs b/crates/nu-cli/tests/completions.rs index fb293b69b..240b794f6 100644 --- a/crates/nu-cli/tests/completions.rs +++ b/crates/nu-cli/tests/completions.rs @@ -444,6 +444,7 @@ fn file_completion_quoted() { "`te st.txt`".to_string(), "`te#st.txt`".to_string(), "`te'st.txt`".to_string(), + "`te(st).txt`".to_string(), ]; match_suggestions(expected_paths, suggestions) diff --git a/tests/fixtures/quoted_completions/te(st).txt b/tests/fixtures/quoted_completions/te(st).txt new file mode 100644 index 000000000..e69de29bb