Add option to create launch config in workspace file by jeanp413 · Pull Request #97321 · microsoft/vscode
| 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:
- Open a folder
f1 - Add to workspace folder
f2. An untitled workspace will be created - Remove folder
f1andf2from the workspace. At this point we have no folders in the workspace. this.contextService.getWorkbenchStatereturnsWorkbenchState.WORKSPACE(is this expected?) so theopenConfigFilefunction gets called.
Thinking more about this I'll move that check hereif (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..
Thanks a lot for this PR, great work!
I have left some comments in the PR, can you please address them. Also
- There seems to be a conflict, can you please resolve it (just removing
sideBySideoptions should do it) - 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?
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.
☀️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
