Skip to content

Conversation

@gjsjohnmurray
Copy link
Contributor

This PR fixes #124020

@isidorn isidorn self-assigned this Aug 13, 2021
@isidorn isidorn added this to the August 2021 milestone Aug 13, 2021
const label = error.urlLabel ? error.urlLabel : nls.localize('moreInfo', "More Info");
const uri = URI.parse(url);
// Use a suffixed id if uri invokes a command, so default 'Open launch.json' command is suppressed on dialog
const actionId = uri.scheme === 'command' ? 'debug.moreInfo.command' : 'debug.moreInfo';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

const configureAction = new Action(DEBUG_CONFIGURE_COMMAND_ID, DEBUG_CONFIGURE_LABEL, undefined, true, () => this.commandService.executeCommand(DEBUG_CONFIGURE_COMMAND_ID));
const actions = [...errorActions, configureAction];
// Don't append the standard command if id of any provided action indicates it is a command
const actions = errorActions.filter((action) => action.id.endsWith('.command')).length > 0 ? errorActions : [...errorActions, configureAction];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have to check here if it endsWith. That feels a bit hacky?
Maybe just if it contains the word command?

Or even better can we use the ICommandRegistry to check if the getCommand exists for that id. That way we will know if the command is good or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a convention I devised so handleErrorResponse in rawDebugSession.ts can indicate that the Action it supplied (currently only one) invokes a command. Here in showError I don't think there's any way I can discover this directly from the Action.

Another idea would be for handleErrorResponse to set the id of the Action to 'command:' followed by the id of the command (i.e. uri.authority), then make this check startsWith('command:'). It could even use match to extract the command id, then validate using ICommandRegistry. In that case, what's best to do if it fails validation? Omit the action from the messagebox? Or add it but disabled? Or don't suppress the DEBUG_CONFIGURE_COMMAND_ID?

What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the current approach makes sense, and that your second proposal is very similar but just might complicate the implementation a bit. Due to that I suggest to go with the current approach.

@isidorn isidorn added the debug Debug viewlet, configurations, breakpoints, adapter issues label Aug 13, 2021
@isidorn
Copy link
Collaborator

isidorn commented Aug 13, 2021

@gjsjohnmurray thanks a lot for this PR. I have commented directly in the code, let me know once you tackle my comments! Thanks!

@isidorn
Copy link
Collaborator

isidorn commented Aug 13, 2021

Thank you very much, this looks good. Merging in 👏 ☀️

@isidorn isidorn merged commit 0f605f0 into microsoft:main Aug 13, 2021
@gjsjohnmurray gjsjohnmurray deleted the fix-124020 branch August 16, 2021 07:09
@github-actions github-actions bot locked and limited conversation to collaborators Sep 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

debug Debug viewlet, configurations, breakpoints, adapter issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suppress default 'Open launch.json' button if debug adapter returns error with command-type actions

2 participants