I'm using VS Code Studio for Flutter. I cannot delete some devices in the Run and Debug section in VS Code Studio, the devices I marked in green in the picture. There are devices that are not in my launch.json file, how do I clear these devices?

Screenshot_VSCode_RunAndDebug

My json file content;

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Android",
            "program": "lib/main.dart",
            "deviceId": "emulator-5554",
            "request": "launch",
            "type": "dart",
            "flutterMode": "debug"
        },
        {
            "name": "Chrome",
            "program": "lib/main.dart",
            "deviceId": "chrome",
            "request": "launch",
            "type": "dart",
            "flutterMode": "debug"
        },
    ],
    "compounds": [
        {
            "name": "All Devices",
            "configurations": [
                "Android",
                "Chrome"
            ]
        }
    ]
}
1

There are 1 answers

0
starball On BEST ANSWER

Not all of those are actually "Devices" in the Dart/Flutter sense of the word. More generically, these are launch configurations. The dropdown is for selecting launch configurations.

The one in your screenshot named CMake: CMake Script is registered dynamically by the CMake Tools extension. There related blog documentation about it here.

The other Flutter ones highlighted in your screenshot are also dynamically generated- by the Dart extension. If you're interested in how it's deciding what to provide dynamically, see https://github.com/Dart-Code/Dart-Code/blob/master/src/shared/vscode/device_manager.ts#L318

To generalize, if you want to figure out why a launch configuration is listed for selection without you defining it manually anywhere, then go read the source code of your extensions and find out where / how they use VS Code's DebugConfigurationProvider API. If they enable any mechanism for you to control it, great. If they don't, either accept it, or try to think of a feature request you'd like to make and raise an issue ticket in the extension's issue tracker requesting that feature.