Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unhandled promise rejections for debug commands #155220

Merged
merged 1 commit into from Jul 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 20 additions & 22 deletions src/vs/workbench/contrib/debug/browser/debugCommands.ts
Expand Up @@ -304,27 +304,27 @@ CommandsRegistry.registerCommand({

CommandsRegistry.registerCommand({
id: REVERSE_CONTINUE_ID,
handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
getThreadAndRun(accessor, context, thread => thread.reverseContinue());
handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
await getThreadAndRun(accessor, context, thread => thread.reverseContinue());
}
});

CommandsRegistry.registerCommand({
id: STEP_BACK_ID,
handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
const contextKeyService = accessor.get(IContextKeyService);
if (CONTEXT_DISASSEMBLY_VIEW_FOCUS.getValue(contextKeyService)) {
getThreadAndRun(accessor, context, (thread: IThread) => thread.stepBack('instruction'));
await getThreadAndRun(accessor, context, (thread: IThread) => thread.stepBack('instruction'));
} else {
getThreadAndRun(accessor, context, (thread: IThread) => thread.stepBack());
await getThreadAndRun(accessor, context, (thread: IThread) => thread.stepBack());
}
}
});

CommandsRegistry.registerCommand({
id: TERMINATE_THREAD_ID,
handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
getThreadAndRun(accessor, context, thread => thread.terminate());
handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
await getThreadAndRun(accessor, context, thread => thread.terminate());
}
});

Expand Down Expand Up @@ -467,12 +467,12 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
weight: KeybindingWeight.WorkbenchContrib,
primary: isWeb ? (KeyMod.Alt | KeyCode.F10) : KeyCode.F10, // Browsers do not allow F10 to be binded so we have to bind an alternative
when: CONTEXT_DEBUG_STATE.isEqualTo('stopped'),
handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
const contextKeyService = accessor.get(IContextKeyService);
if (CONTEXT_DISASSEMBLY_VIEW_FOCUS.getValue(contextKeyService)) {
getThreadAndRun(accessor, context, (thread: IThread) => thread.next('instruction'));
await getThreadAndRun(accessor, context, (thread: IThread) => thread.next('instruction'));
} else {
getThreadAndRun(accessor, context, (thread: IThread) => thread.next());
await getThreadAndRun(accessor, context, (thread: IThread) => thread.next());
}
}
});
Expand All @@ -486,12 +486,12 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
primary: STEP_INTO_KEYBINDING,
// Use a more flexible when clause to not allow full screen command to take over when F11 pressed a lot of times
when: CONTEXT_DEBUG_STATE.notEqualsTo('inactive'),
handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
const contextKeyService = accessor.get(IContextKeyService);
if (CONTEXT_DISASSEMBLY_VIEW_FOCUS.getValue(contextKeyService)) {
getThreadAndRun(accessor, context, (thread: IThread) => thread.stepIn('instruction'));
await getThreadAndRun(accessor, context, (thread: IThread) => thread.stepIn('instruction'));
} else {
getThreadAndRun(accessor, context, (thread: IThread) => thread.stepIn());
await getThreadAndRun(accessor, context, (thread: IThread) => thread.stepIn());
}
}
});
Expand All @@ -501,12 +501,12 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyMod.Shift | KeyCode.F11,
when: CONTEXT_DEBUG_STATE.isEqualTo('stopped'),
handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
const contextKeyService = accessor.get(IContextKeyService);
if (CONTEXT_DISASSEMBLY_VIEW_FOCUS.getValue(contextKeyService)) {
getThreadAndRun(accessor, context, (thread: IThread) => thread.stepOut('instruction'));
await getThreadAndRun(accessor, context, (thread: IThread) => thread.stepOut('instruction'));
} else {
getThreadAndRun(accessor, context, (thread: IThread) => thread.stepOut());
await getThreadAndRun(accessor, context, (thread: IThread) => thread.stepOut());
}
}
});
Expand All @@ -516,8 +516,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
weight: KeybindingWeight.WorkbenchContrib + 2, // take priority over focus next part while we are debugging
primary: KeyCode.F6,
when: CONTEXT_DEBUG_STATE.isEqualTo('running'),
handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
getThreadAndRun(accessor, context, thread => thread.pause());
handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
await getThreadAndRun(accessor, context, thread => thread.pause());
}
});

Expand Down Expand Up @@ -649,17 +649,15 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
weight: KeybindingWeight.WorkbenchContrib + 10, // Use a stronger weight to get priority over start debugging F5 shortcut
primary: KeyCode.F5,
when: CONTEXT_DEBUG_STATE.isEqualTo('stopped'),
handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
getThreadAndRun(accessor, context, thread => thread.continue());
handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
await getThreadAndRun(accessor, context, thread => thread.continue());
}
});

CommandsRegistry.registerCommand({
id: SHOW_LOADED_SCRIPTS_ID,
handler: async (accessor) => {

await showLoadedScriptMenu(accessor);

}
});

Expand Down