Skip to content

clap_generate PowerShell script does not complete case sensitive options like -S. Only completes -s #2145

@jfishe

Description

@jfishe

Make sure you completed the following tasks

Code

https://github.com/clap-rs/clap/blob/3e9ee86713b5c407b50ba76f30cffaed25952063/clap_generate/src/generators/shells/powershell.rs

Steps to reproduce the issue

N/A

Version

name = "clap"
version = "2.33.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdfa80d47f954d53a35a64987ca1422f495b8d6483c0fe9f7117b36c2a792129"
dependencies = [
"bitflags",
"strsim",
"textwrap",
"unicode-width",
]

Actual Behavior Summary

https://github.com/BurntSushi/ripgrep generated _rg.ps1 does not complete -S correctly. It only completes -s.

Expected Behavior Summary

See BurntSushi/ripgrep#1690 for details.

. _rg.ps1

rg -s<Ctrl-Space> completes rg -s. It should produce:

rg -s
s   S

Search case sensitively (default).

A simple fix would be to change ListItemText for 'S' to 'S '. The space makes ListItemText unique, which is all that's needed.

Additional context

A simple fix may be to test for upper case and append a space. I don't know rust, so a PR is beyond me.

and
"'-{}', '{}', {}, '{}')",

For example, change the second '{}' to '{} ' in the format! below after adding a check for upper case. Sorry I can't be more helpful.

if let Some(short_aliases) = option.get_visible_short_aliases() {
                for data in short_aliases {
                    completions.push_str(&preamble);
                    completions.push_str(
                        format!(
                            "'-{}', '{} ', {}, '{}')",
                            data, data, "[CompletionResultType]::ParameterName", tooltip
                        )
                        .as_str(),
                    );
                }
            }
        }

Debug output

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    💸 $5A-completionArea: completion generatorC-bugCategory: bugE-mediumCall for participation: Experience needed to fix: Medium / intermediate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions