Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use single best completion item for commands, options, and global options#1700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
baronfel wants to merge1 commit intodotnet:main
base:main
Choose a base branch
Loading
frombaronfel:reduce-completions-noise

Conversation

@baronfel
Copy link
Member

This is an attempt to make completions less noisy by using the most relevant available alias for each Subcommand or Option provided for completions. Currently, each of these adds all of its aliases to the pool of available completions, which is quite noisy and can be distracting to a user. Imagine a shell that displays descriptions for completions. Would you want completions at the top-level of the command to emit all 5 Help Option aliases on new rows, along with the same description? I don't think so.

Instead, we try to find thebest alias for the Subcommand or Option. What 'best' means varies by context:

  • when the user hasn't typed any part of the subcommand or option, the best should be the longest alias. This is typically a most-descriptive form of the option. While such an alias might be a pain to type out manually, with tab completion we can trade precision for verbosity in a way that costs very little effort.
  • when the user has typed a part of the subcommand or option, we use that stem to:
    • filter the aliases by those that contain the stem
    • sort those descending by Levenstein distance ---------------------- These two steps are taken from the TypoCorrection middleware, it seemed good and relevant to reuse this algorithm
    • then sort descending by the length of the matching starting stem _/
    • then take the first match

Left to do:

  • get feedback on algorithm
  • add tests specifically around verifying that only one alias is returned per option

@baronfelbaronfelforce-pushed thereduce-completions-noise branch from4e302af to679c60dCompareApril 5, 2022 19:14
{
#ifNET6_0_OR_GREATER
""=> aliases.MaxBy(a=>a.Length),// find the longest alias
(stringstem)=> aliases.Where(a=>a.Contains(stem,StringComparison.OrdinalIgnoreCase)).OrderByDescending(a=>TokenDistances.GetLevensteinDistance(stem,a)).ThenByDescending(a=>TokenDistances.GetStartsWithDistance(stem,a)).FirstOrDefault()
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

usealias.ContainsCaseInsensitive extension method instead here to remove TFM split

@KalleOlaviNiemitalo
Copy link

the best should be the longest alias

Consider using the first alias, or even Symbol.Name. This would give the app developer better control on which alias is preferred.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@baronfel@KalleOlaviNiemitalo

[8]ページ先頭

©2009-2025 Movatter.jp