From e9336527708f80047a481f183c67fa9c68700129 Mon Sep 17 00:00:00 2001 From: Dom Slee Date: Mon, 9 Sep 2024 21:25:07 +1000 Subject: [PATCH] Fix $ completions --- src/completer.rs | 3 ++- tests/test_complete_npm.rs | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/completer.rs b/src/completer.rs index 39c5d60..0ce04ff 100644 --- a/src/completer.rs +++ b/src/completer.rs @@ -31,7 +31,8 @@ fn get_suggestion_string(suggestion: &Suggestion) -> String { || arg.contains('\"') || arg.contains('\'') || arg.contains('`') - || arg.contains('&')) + || arg.contains('&') + || arg.contains('$')) { let replaced_arg = arg.replace('\'', "''"); return format!("'{replaced_arg}'"); diff --git a/tests/test_complete_npm.rs b/tests/test_complete_npm.rs index 9b971c1..108f5ab 100644 --- a/tests/test_complete_npm.rs +++ b/tests/test_complete_npm.rs @@ -98,3 +98,20 @@ fn test_npm_run_ampersand(shell: &str) -> Result<(), std::io::Error> { assert_that!(&lines).equals_iterator(&[r#"'with&ersand'"#.to_string()].iter()); Ok(()) } + +#[apply(shell_to_use)] +fn test_npm_run_dollar(shell: &str) -> Result<(), std::io::Error> { + let test_env = TestEnv::new(shell).create_package_json( + r#" + { + "scripts": { + "with$dollar": "echo hello world", + } + } + "#, + )?; + + let lines = util::run_with_test_env(&test_env, "Invoke-TabComplete 'npm run with'"); + assert_that!(&lines).equals_iterator(&[r#"'with$dollar'"#.to_string()].iter()); + Ok(()) +}