Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: include language keywords in command completion results #10221

Closed
msftrncs opened this issue Jul 24, 2019 · 10 comments · May be fixed by #21171
Closed

Feature Request: include language keywords in command completion results #10221

msftrncs opened this issue Jul 24, 2019 · 10 comments · May be fixed by #21171
Labels
In-PR Indicates that a PR is out for the issue Issue-Enhancement the issue is more of a feature request than a bug Resolution-No Activity Issue has had no activity for 6 months or more WG-Interactive-IntelliSense tab completion

Comments

@msftrncs
Copy link
Contributor

msftrncs commented Jul 24, 2019

Summary of the new feature/enhancement

Include language keywords, such as 'continue', 'switch', 'foreach', etc... in with the command completions offered by intellisense/tab completion.

Proposed technical implementation details (optional)

I don't yet know if its possible to restrict the keywords when the insertion point is not the first command in a pipeline, but there is already 1 case in the completion logic that has decided that foreach should not have an ampersand & (invoke) operator inserted before it (its actually in the completions because its an alias for ForEach-Object) because its more likely what the user wanted, but none of the other keywords get this treatment. Including the keywords would actually eliminate this special case.

I am sure somewhere there is a complete list of keywords in the code, I'm just not sure if there is anything to use as a tooltip text readily available.

I may experiment on this while working the other bugs out of the completion code.

@msftrncs msftrncs added the Issue-Enhancement the issue is more of a feature request than a bug label Jul 24, 2019
@vexx32
Copy link
Collaborator

vexx32 commented Jul 24, 2019

Might want to clarify your issue title; it seems the request is for language keywords to show in tab-completion results where appropriate, rather than for commands to show (which they already do). 🙂

But yep, agreed, not sure why we don't include keywords.

@msftrncs msftrncs changed the title Feature Request: include commands in command completion results Feature Request: include language keywords in command completion results Jul 24, 2019
@msftrncs
Copy link
Contributor Author

Thanks, @vexx32, sometimes I speak better computer than English. :)

@iSazonov iSazonov added the WG-Interactive-IntelliSense tab completion label Jul 25, 2019
@HumanEquivalentUnit
Copy link
Contributor

I am sure somewhere there is a complete list of keywords in the code

Yes, here in the tokenizer. Copying it in:

private static readonly string[] s_keywordText = new string[] {
    /*1*/    "elseif",                  "if",               "else",             "switch",                     /*1*/
    /*2*/    "foreach",                 "from",             "in",               "for",                        /*2*/
    /*3*/    "while",                   "until",            "do",               "try",                        /*3*/
    /*4*/    "catch",                   "finally",          "trap",             "data",                       /*4*/
    /*5*/    "return",                  "continue",         "break",            "exit",                       /*5*/
    /*6*/    "throw",                   "begin",            "process",          "end",                        /*6*/
    /*7*/    "dynamicparam",            "function",         "filter",           "param",                      /*7*/
    /*8*/    "class",                   "define",           "var",              "using",                      /*8*/
    /*9*/    "workflow",                "parallel",         "sequence",         "inlinescript",               /*9*/
    /*A*/    "configuration",           "public",           "private",          "static",                     /*A*/
    /*B*/    "interface",               "enum",             "namespace",        "module",                     /*B*/
    /*C*/    "type",                    "assembly",         "command",          "hidden",                     /*C*/
    /*D*/    "base",                                                                                          /*D*/
};

I'm just not sure if there is anything to use as a tooltip text readily available.

Would that be beneficial? If you autocomplete notepad.exe you don't get very useful tooltip information.

@msftrncs
Copy link
Contributor Author

Would that be beneficial? If you autocomplete notepad.exe you don't get very useful tooltip information.

That's because notepad.exe isn't part of PowerShell. You do on the other hand still get the complete path to notepad.exe in the tooltip. I think something in the tooltip needs to let the user know that this is the keyword, vs the function. Some functions do not show anything in their tooltip, so if both functions and keywords both showed nothing in the tooltip it might be slightly confusing, however, at least a command with the same name as a keyword requires the & and that will show when its selected.

Interestingly I see the operators are already included in completions, and they have tooltips.

Any data kept on whether these keywords are available, or better, available in a given context? I would think that reserved keywords should probably not have completions offered, so that a user doesn't have as much clutter to sort through, and keywords that are not available in the current context should not be offered.

I suppose that last part is what has kept keyword completion from being implemented so far.

@andyleejordan
Copy link
Member

@SeeminglyScience is there any reason we don't auto-complete language keywords currently?

@SeeminglyScience
Copy link
Collaborator

Aside from complexity and demand not that I know of. It's not exactly as simple as it first seems since you have to add logic for only returning a keyword completion result when it's actually applicable and that branch of code doesn't exist yet. That's pretty minor, but still

Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

2 similar comments
Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

Copy link
Contributor

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

@microsoft-github-policy-service microsoft-github-policy-service bot added Resolution-No Activity Issue has had no activity for 6 months or more labels Nov 16, 2023
Copy link
Contributor

This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.

@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR Indicates that a PR is out for the issue label Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In-PR Indicates that a PR is out for the issue Issue-Enhancement the issue is more of a feature request than a bug Resolution-No Activity Issue has had no activity for 6 months or more WG-Interactive-IntelliSense tab completion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants