Skip to content

Commit

Permalink
Fix $ completions
Browse files Browse the repository at this point in the history
  • Loading branch information
domsleee committed Sep 9, 2024
1 parent d092c52 commit e933652
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/completer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}'");
Expand Down
17 changes: 17 additions & 0 deletions tests/test_complete_npm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,20 @@ fn test_npm_run_ampersand(shell: &str) -> Result<(), std::io::Error> {
assert_that!(&lines).equals_iterator(&[r#"'with&ampersand'"#.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(())
}

0 comments on commit e933652

Please sign in to comment.