Key binding command to add arbitrary files to context

I would like to add a key binding to my keybindings.json that opens a new instance of Cursor Composer with a set predetermined files and folders already in the context.

I tried 2 different approaches:

  • the composer.addfilestonnewcomposer command (it only adds the currently open file to the context;
  • a combination of composer.createNew and composer.addfilestocomposer as follows
{
    "key": "cmd+shift+e",
    "command": "runCommands",
    "args": {
      "commands": [
        "composer.createNew",
        {
          "command": "workbench.action.quickOpen",
          "args": "<file_path>"
        },
        "workbench.action.acceptSelectedQuickOpenItem",
        "composer.addfilestocomposer",
        {
          "command": "workbench.action.quickOpen",
          "args": "<another_file_path>"
        },
        "workbench.action.acceptSelectedQuickOpenItem",
        "composer.addfilestocomposer",
        "composer.openControlPanel",
      ]
    }
  }

But this also fails to add the files to the context. Also, I’d want to add a whole folder so even if it worked, it’d fall short.

It would be great to have a composer.addFilesToContext command that takes files and folders arrays as arguments and adds them to the context of Composer.
Somethings along the lines of:

{
    "key": "cmd+shift+e",
    "command": "runCommands",
    "args": {
      "commands": [
        "composer.createNew",
        {
          "command": "composer.addFilesToContext",
          "args": {
            "files": [
              "<file_path>"
            ],
            "folders": [
              "<folder_path>"
            ]
          }
        },
        "composer.openControlPanel",
      ]
    }
  }
1 Like