interactive icon indicating copy to clipboard operation
interactive copied to clipboard

PowerShell: CompletionItemProvider Doesn't Display Options

Open 0xNinshu opened this issue 2 years ago • 7 comments

Describe the bug

I am using the dotnet-interactive kernel with the #!pwsh magic command. When attempting to trigger suggestions (quick, trigger character, or control + space) the completion list will not be presented when attempting to get a list of options for function names, parameters and snippets. I have tried the dotnet-interactive Jupiter kernel the completion list shows.

It's taken me some time to make sure that I hadn't misconfigured something. I have tried reinstalling vscode, dotnet, the PowerShell extension, nothing is changing this issue. I initially thought this was just a limitation of polyglot notebooks. I changed the log level of the extension and switched the output panel to Polyglot Notebook: Logging and noticed the completion items were being logged when pressing ctrl + space to get a list of parameters for the function New-ModuleManifest. But the completion list is not being presented.


I have attached 2 log files that give the messages I could find, and a video of the issue below.

VSCode profile settings.json

settings.txt


Logs

output.log 20230505-00001.log


Issue Clip

https://user-images.githubusercontent.com/96320396/236365800-7316873e-c3a1-4642-8cbb-38cc2c19f8b3.mp4

Please complete the following:

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ):

 Version: 1.0.420401+9ca2fc354b82d355712f8bbc0c36194e36fe9ee7
 Library version: 1.0.0-beta.23204.1+9ca2fc354b82d355712f8bbc0c36194e36fe9ee7
 Build date: 2023-04-13T00:12:39.8874746Z

  • OS

    • [x ] Windows 11
    • [ ] Windows 10
    • [ ] macOS
    • [ ] Linux (Please specify distro)
    • [ ] iOS
    • [ ] Android
  • Frontend

    • [ ] Jupyter Notebook
    • [ ] Jupyter Lab
    • [ ] nteract
    • [x ] Visual Studio Code
    • [ ] Visual Studio Code Insiders
    • [ ] Visual Studio
    • [ ] Other (please specify)

0xNinshu avatar May 05 '23 06:05 0xNinshu

I haven't been able to reproduce this issue. Can you still reproduce it?

jonsequitur avatar Jun 19 '23 23:06 jonsequitur

@jonsequitur yes. I am also still seeing the same logging aswell that was present before. The log has the result but it doesn't show me the suggestion pop up.

[Info] extension host: envelope received from stdio: {
    "event": {
        "linePositionSpan": {
            "start": {
                "line": 2,
                "character": 9
            },
            "end": {
                "line": 2,
                "character": 10
            }
        },
        "completions": [
            {
                "displayText": "-Date",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[datetime] Date"
            },
            {
                "displayText": "-UnixTimeSeconds",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[long] UnixTimeSeconds"
            },
            {
                "displayText": "-Year",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[int] Year"
            },
            {
                "displayText": "-Month",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[int] Month"
            },
            {
                "displayText": "-Day",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[int] Day"
            },
            {
                "displayText": "-Hour",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[int] Hour"
            },
            {
                "displayText": "-Minute",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[int] Minute"
            },
            {
                "displayText": "-Second",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[int] Second"
            },
            {
                "displayText": "-Millisecond",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[int] Millisecond"
            },
            {
                "displayText": "-DisplayHint",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[DisplayHintType] DisplayHint"
            },
            {
                "displayText": "-UFormat",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[string] UFormat"
            },
            {
                "displayText": "-Format",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[string] Format"
            },
            {
                "displayText": "-AsUTC",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[switch] AsUTC"
            },
            {
                "displayText": "-Verbose",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[switch] Verbose"
            },
            {
                "displayText": "-Debug",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[switch] Debug"
            },
            {
                "displayText": "-ErrorAction",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[ActionPreference] ErrorAction"
            },
            {
                "displayText": "-WarningAction",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[ActionPreference] WarningAction"
            },
            {
                "displayText": "-InformationAction",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[ActionPreference] InformationAction"
            },
            {
                "displayText": "-ErrorVariable",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[string] ErrorVariable"
            },
            {
                "displayText": "-WarningVariable",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[string] WarningVariable"
            },
            {
                "displayText": "-InformationVariable",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[string] InformationVariable"
            },
            {
                "displayText": "-OutVariable",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[string] OutVariable"
            },
            {
                "displayText": "-OutBuffer",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[int] OutBuffer"
            },
            {
                "displayText": "-PipelineVariable",
                "kind": "ParameterName",
                "filterText": null,
                "sortText": null,
                "insertText": null,
                "insertTextFormat": null,
                "documentation": "[string] PipelineVariable"
            }
        ]
    },
    "eventType": "CompletionsProduced",
    "command": {
        "token": "L9x7BkMMSlmjjQvKqTgleA==.1",
        "id": "9ea2435c44b849029b32dbd08e248da6",
        "commandType": "RequestCompletions",
        "command": {
            "code": "Get-Date -\r\n\r\n",
            "linePosition": {
                "line": 0,
                "character": 10
            },
            "targetKernelName": "pwsh",
            "originUri": null,
            "destinationUri": null
        },
        "routingSlip": [
            "kernel://pid-86472/?tag=arrived",
            "kernel://pid-86472/pwsh?tag=arrived"
        ]
    },
    "routingSlip": [
        "kernel://pid-86472/pwsh",
        "kernel://pid-86472/"
    ]
}
[Info] webview: channel got CompletionsProduced with token L9x7BkMMSlmjjQvKqTgleA==.1 and id 9ea2435c44b849029b32dbd08e248da6
[Info] webview: channel got CommandSucceeded with token L9x7BkMMSlmjjQvKqTgleA== and id XK/hP88FTWiSlahzP60bDQ==

0xNinshu avatar Jun 22 '23 23:06 0xNinshu

I have determined the cause of the issue @jonsequitur, the completion item is being classified as text / words. I have my settings set to not suggest words to me because it clutters up the results. I am going to fix this by enabling it for polyglot-notebooks with the setting below.

    "[polyglot-notebook]": {
        "editor.suggest.showWords": true
    },

I do think that this requires further investigation as to the root cause I have spent several hours looking over the code, I don't know enough about language providers to be able to determine if my findings are the actual issue. But I do want to mention a few things that may be the problem.

Completion Item Mapping

The code I am going to reference can be found here: languageProvider.ts. In the language provider I noticed a mapping between the Roslyn - WellknownTags.cs and vscode.CompletionItemKind Enum members. The mapping is incomplete, the Roselyn wellknowntags in the language section has additional members that are not in use. I am not sure if this is by design, if not here are the suggested mappings for the missing members.

case "Intrinsic": return vscode.CompletionItemKind.Property
case "Keyword": return vscode.CompletionItemKind.Keyword
case "Label": return vscode.CompletionItemKind.Operator
case "Operator": return vscode.CompletionItemKind.Operator
case "Parameter": return vscode.CompletionItemKind.Property
case "RangeVariable": return vscode.CompletionItemKind.Variable
case "Reference": return vscode.CompletionItemKind.Reference
case "TypeParameter": return vscode.CompletionItemKind.TypeParameter

I also noticed 1 of the mappings doesn't exist in the list of Roslyn language elements, the "Value" mapping.

case "Value": return vscode.CompletionItemKind.Value;

I have been messing with the extension. I can try to see if I can fix it, I have never worked with a project of this complexity. Let me know your thoughts.

0xNinshu avatar Jul 28 '23 17:07 0xNinshu

@jonsequitur still waiting on a reply from you.

0xNinshu avatar Oct 02 '23 16:10 0xNinshu

I'm still unable to repro the issue. I wonder if there's something else in your setup that's interfering.

image

jonsequitur avatar Oct 02 '23 19:10 jonsequitur

@jonsequitur did you set editor.suggest.showWords in your global user settings to false? Like I was saying before I am working around the issue, by configuring this setting on a language level for polyglot notebooks. I will include the exact repro settings below.

It's a key indicator that the completion is getting misclassified due to the abc icon next to the items in the image you posted.

Fail Settings

"editor.suggest.showWords": false,
"[polyglot-notebook]": {
    "editor.suggest.showWords": false
}

Work Around Settings

"editor.suggest.showWords": false,
"[polyglot-notebook]": {
    "editor.suggest.showWords": true
}

0xNinshu avatar Oct 09 '23 01:10 0xNinshu

Ah, I see. Thanks for clarifying. Yes, those settings repro the issue for me.

jonsequitur avatar Oct 09 '23 21:10 jonsequitur