Add option to create launch config in workspace file by jeanp413 · Pull Request #97321 · microsoft/vscode

@jeanp413

@jeanp413

isidorn

async openConfigFile(sideBySide: boolean, preserveFocus: boolean, type?: string, token?: CancellationToken): Promise<{ editor: IEditorPane | null, created: boolean }> {
const ws = this.contextService.getWorkspace();

if (ws.folders.length === 0) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this check necesery?
If I do not have any folders in the workspace I do not even get offered "workspace" in the quick pick

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an edge case I found with the following steps:

  1. Open a folder f1
  2. Add to workspace folder f2. An untitled workspace will be created
  3. Remove folder f1 and f2 from the workspace. At this point we have no folders in the workspace.
  4. this.contextService.getWorkbenchState returns WorkbenchState.WORKSPACE (is this expected?) so the openConfigFile function gets called.
    Thinking more about this I'll move that check here
    if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that state is the empty workspace state - you are stil in a workspace just do not have any folder in the workspace. So you are correct we should cover that case. Thanks

if (!launchExistInFile) {
// Launch property in workspace config not found: create one by collecting launch configs from debugConfigProviders
let content = '';
const adapter = await this.configurationManager.guessDebugger(type);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we have similar code in the Launch. Might it make sense to extract this code to the AbstractLaunch so both clases use it? Not sure if 100% good idea..

@isidorn

Thanks a lot for this PR, great work!
I have left some comments in the PR, can you please address them. Also

  1. There seems to be a conflict, can you please resolve it (just removing sideBySide options should do it)
  2. I am not a fan of the current UI. Can we change "workspace" to be "Workspace". Can we change the placeholder message to also mention this new optoin?

Screenshot 2020-05-11 at 13 00 26

@jeanp413

@jeanp413

@jeanp413

Pushed some changes addressing the feedback

@isidorn

Thanks a lot for this PR. Merging in.
I am doing some changes in that file at the moment so I might polish it a bit on top.
☀️