rioj7 / command-variable

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

Is it available to filter out filename included inside some folder? #88

Closed zhuoqun-chen closed 2 months ago

zhuoqun-chen commented 2 months ago

Hi @rioj7, I have a question to ask and wish you could kindly give me some help. I saw this example at here:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "cpp lint",
      "type": "shell",
      "command": "cpplint ${input:selectDir}"
    }
  ],
  "inputs": [
    {
      "id": "selectDir",
      "type": "command",
      "command": "extension.commandvariable.pickStringRemember",
      "args": {
        "description": "Which directory to Lint for C++?",
        "options": [
          ["Use previous directory", "${remember:srcSubDir}"],
          ["All", "all"],
          ["Pick directory", "${pickFile:srcSubDir}"]
        ],
        "default": null,
        "pickFile": {
          "srcSubDir": {
            "description": "Which directory?",
            "include": "src/**/*.{cpp,h}",
            "showDirs": true,
            "keyRemember": "srcSubDir"
          }
        }
      }
    }
  ]
}

This can only filter out the folderpath as input in the end. But if I want to pick exactly a file named, eg, hello.cpp among so many *.cpp, and make the <long_prefix>/hello.cpp as the input to my task? Is it doable?

rioj7 commented 2 months ago

@zhuoqun-chen If you remove the "showDirs": true property you get a list of the files that match and there path should be the result of the ${pickFile:srcSubDir} variable. You can use "smart filter"(??) by typing part of the file name when the file list is displayed.

If it works rename all the dir stuff to file stuff.

zhuoqun-chen commented 2 months ago

Thank you @rioj7, I haven't figure out what is smart filter(??), but after removing "showDirs": true, it indeed show me a file list and allow me to select a file that matches "include": "run/**/cfg_*.yaml" pattern in many folders that contain them, thank you!

rioj7 commented 2 months ago

@zhuoqun-chen smart filter or fuzzy filter only shows the labels that contain the typed characters in that order followed by the labels that contain these characters somewhere, just like you use the Command Palette, type cursor to see only commands related to cursor operations.