rioj7 / command-variable

Visual Studio Code extension for variable substitution via ${command:commandID}
54 stars 10 forks source link

pickStringRemember issue since 1.65.x #94

Closed axelnxp closed 2 months ago

axelnxp commented 3 months ago

Hi,

I updated the extension to 1.65.0 and 1.65.2, and got issues with pickStringRemember command. My command definition is the following:

            "id": "JLinkSerial",
            "type": "command",
            "command": "extension.commandvariable.pickStringRemember",
            "args": {
                "description": "Select the JLink serial to debug:",
                "fileName": "${workspaceFolder}/.vscode/configs/jlink_setup.cfg",
                "pattern": {
                    "regexp": "^([^#].*)=(.*\\d)",
                    "label": "$1",
                    "value": "$2"
                },
                "checkEscapedUI": true
            },

The idea is to look in a file for strings like foo=1234567890 and then to provide the choice to the user.

This worked up to 1.64.0, but starting from 1.65.0, the returned list is empty.

Do I need to update my command for the latest version of the extension ? If you need debug logs, how can I provide them to you ?

yyc commented 3 months ago

we're running into a similar issue on 1.65.0 and 1.65.1. I think #93 will fix it.

We're temporarily using a workaround until it's fixed and a new version of the extension is released. Could you try adding "json": "" to your pattern object? So

                "pattern": {
                    "regexp": "^([^#].*)=(.*\\d)",
                    "label": "$1",
                    "value": "$2",
                    "json": ""
                },
rioj7 commented 3 months ago

@axelnxp fixed in v1.65.3 ( 6453d62 )

I think a better pattern for your use case is:

        "pattern": {
          "regexp": "^(?!#)(.*?)=(\\d*)",
          "label": "$1",
          "value": "$2"
        },
axelnxp commented 2 months ago

@rioj7 I'm testing the new version, it works but in the pickList, I don't see the value printed alongside the label, I can only see the label. Is it expected ? How can I see the value ? In my case, the list can show multiple label that are the same, it's the value that helps me choose between them.

rioj7 commented 2 months ago

@axelnxp The value is never shown, you have to set the description or detail field or modify the string for the label to see extra information in the list. The label needs to be unique. It is used as key to determine what is picked.

What you could do is:

        "pattern": {
          "regexp": "^(?!#)(.*?)=(\\d*)",
          "label": "$1 - $2",
          "value": "$2"
        },
axelnxp commented 2 months ago

@rioj7 On 1.64.0, I can see the value in the list: image

Then on 1.65.3, I don't see it: image

is this expected ?

rioj7 commented 2 months ago

@axelnxp try v1.65.4

In v1.64 I use the [label, value] method to pass the option to the quickpick builder, and that sets description equal to the string version of value. In v1.65 I changed to use the option method to be able to set description and detail without adding a lot of code and make it do the same as the json from file.

Also fixed the display: if you only have labels in the file the label is not shown twice.

axelnxp commented 2 months ago

@rioj7 Just tried, works well now ! Thanks for the fix :)