Skip to content

Better "when clause" with full path support #105390

@datismoa

Description

@datismoa

This proposal is a slightly improved version of an already existing suggestion which was rejected.

I would like to have more flexibility using when clause contexts. It would be nice if I could specify some directory or certain files of a directory with no nesting restrictions.

Let's take a look at 2 cases of this concept:

  • I want to capture the path relative to the root of the project:
{
  "menus": {
    "explorer/context": [
      {
        "command": "ext.executeConfigFile",
        "when": "resourceFilePath == /^\/$/"
      }
    ]
  }
}

Here I expect that the option in the context menu will only appear when the root (/) directory is selected.

  • I want to capture the path relative to a directory or even a file:
{
  "menus": {
    "explorer/context": [
      {
        "command": "ext.executeConfigFile",
        "when": "resourceFilePath == /^\/Components\/User\/(?:[a-zA-Z0-9_]+).js$/"
      }
    ]
  }
}

Here I expect that the option in the context menu will appear only when a file is selected by a specified regular expression in the directory /Components/User/.

How are things now?

I do not know how to solve this problem related to such a situation using when clause contexts. So I reckon this is a powerful and necessary feature that needs to be implemented.

Metadata

Metadata

Assignees

Labels

*out-of-scopePosted issue is not in scope of VS Codefeature-requestRequest for new features or functionality

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions