eclipse-theia / theia

Eclipse Theia is a cloud & desktop IDE framework implemented in TypeScript.
http://theia-ide.org
Eclipse Public License 2.0
20.03k stars 2.5k forks source link

Support Workspace Launch Configuration #8836

Open RomanNikitenko opened 3 years ago

RomanNikitenko commented 3 years ago

Feature Description:

VS Code supports adding launch configurations to the workspace configuration file.

Please see more details here: https://code.visualstudio.com/docs/editor/multi-root-workspaces#_workspace-launch-configurations

RomanNikitenko commented 3 years ago

Theia supports Workspace Launch configurations.

The configurations should be defined in workspace config file like:

"settings": {
        "launch": {
            "configurations": [
                {
                    "name": "Launch Chrome",
                    "request": "launch",
                    "type": "pwa-chrome",
                    "url": "http://localhost:8080",
                    "webRoot": "${workspaceFolder}"
                }
            ]
        }
    },

At creating the issue I tested another format described in the docs of VS Code: https://code.visualstudio.com/docs/editor/multi-root-workspaces#_workspace-launch-configurations, so like:

"launch": {
    "configurations": [
      {
        "name": "Launch Chrome",
        "request": "launch",
        "type": "pwa-chrome",
        "url": "http://localhost:8080",
        "webRoot": "${workspaceFolder}"
      }
    ],
    "compounds": []
  },

Please pay attention that for the first case the configuration is placed within settings object. The second way (launch field is outside settings) doesn't work for Theia at the moment.

VS Code supports both formats: configs inside and outside settings. But configurations outside settings obscure configs insidesettings - so user should use only one way - either ... either. Please see https://github.com/eclipse-theia/theia/pull/8917#issuecomment-764709137

colin-grant-work commented 3 years ago

A few more details: There are two kinds of clobbering going on.

That means that there are two bugs in the current code:

  1. Workspace-scoped configurations are being associated with folders
  2. Workspace-scoped configurations are not being listed separately.

The cause of the first bug is a peculiarity of the way DebugConfigurationManager.parseConfigurations gets data from PreferenceService.resolve:

https://github.com/eclipse-theia/theia/blob/42042974c59f148974de5e8fd90cba7222cee82f/packages/core/src/browser/preferences/preference-service.ts#L495-L513

Since .resolve loops through all scopes and retrieves data, merging the data as it goes, if it picks up a value for launch from workspace scope and not one from the folder, then it will keep the workspace-scoped value, and the DebugConfigurationModel for the folder will report it as though the data belonged to it.

The cause of the second bug is that in the DebugConfigurationManager there is no DebugConfigurationModel associated with workspace scope.

RomanNikitenko commented 3 years ago

@colin-grant-work thanks for your investigation and provided details!

Yesterday I created one more issue related to launch configurations: https://github.com/eclipse-theia/theia/issues/8985 I created it as enhancement, I thought the current behavior is the result of the first implementation of launch configs in Theia without alignment of the behavior with VS Code.
But now for me it looks like a bug and your investigation contains some details related to the cause of the problem.