Skip to content

Commit 4b6b842

Browse files
authored
Fix unhandled promise rejections for debug commands (microsoft#155220)
Fixes microsoft#154763
1 parent 29e6da6 commit 4b6b842

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

src/vs/workbench/contrib/debug/browser/debugCommands.ts

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -304,27 +304,27 @@ CommandsRegistry.registerCommand({
304304

305305
CommandsRegistry.registerCommand({
306306
id: REVERSE_CONTINUE_ID,
307-
handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
308-
getThreadAndRun(accessor, context, thread => thread.reverseContinue());
307+
handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
308+
await getThreadAndRun(accessor, context, thread => thread.reverseContinue());
309309
}
310310
});
311311

312312
CommandsRegistry.registerCommand({
313313
id: STEP_BACK_ID,
314-
handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
314+
handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
315315
const contextKeyService = accessor.get(IContextKeyService);
316316
if (CONTEXT_DISASSEMBLY_VIEW_FOCUS.getValue(contextKeyService)) {
317-
getThreadAndRun(accessor, context, (thread: IThread) => thread.stepBack('instruction'));
317+
await getThreadAndRun(accessor, context, (thread: IThread) => thread.stepBack('instruction'));
318318
} else {
319-
getThreadAndRun(accessor, context, (thread: IThread) => thread.stepBack());
319+
await getThreadAndRun(accessor, context, (thread: IThread) => thread.stepBack());
320320
}
321321
}
322322
});
323323

324324
CommandsRegistry.registerCommand({
325325
id: TERMINATE_THREAD_ID,
326-
handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
327-
getThreadAndRun(accessor, context, thread => thread.terminate());
326+
handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
327+
await getThreadAndRun(accessor, context, thread => thread.terminate());
328328
}
329329
});
330330

@@ -467,12 +467,12 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
467467
weight: KeybindingWeight.WorkbenchContrib,
468468
primary: isWeb ? (KeyMod.Alt | KeyCode.F10) : KeyCode.F10, // Browsers do not allow F10 to be binded so we have to bind an alternative
469469
when: CONTEXT_DEBUG_STATE.isEqualTo('stopped'),
470-
handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
470+
handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
471471
const contextKeyService = accessor.get(IContextKeyService);
472472
if (CONTEXT_DISASSEMBLY_VIEW_FOCUS.getValue(contextKeyService)) {
473-
getThreadAndRun(accessor, context, (thread: IThread) => thread.next('instruction'));
473+
await getThreadAndRun(accessor, context, (thread: IThread) => thread.next('instruction'));
474474
} else {
475-
getThreadAndRun(accessor, context, (thread: IThread) => thread.next());
475+
await getThreadAndRun(accessor, context, (thread: IThread) => thread.next());
476476
}
477477
}
478478
});
@@ -486,12 +486,12 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
486486
primary: STEP_INTO_KEYBINDING,
487487
// Use a more flexible when clause to not allow full screen command to take over when F11 pressed a lot of times
488488
when: CONTEXT_DEBUG_STATE.notEqualsTo('inactive'),
489-
handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
489+
handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
490490
const contextKeyService = accessor.get(IContextKeyService);
491491
if (CONTEXT_DISASSEMBLY_VIEW_FOCUS.getValue(contextKeyService)) {
492-
getThreadAndRun(accessor, context, (thread: IThread) => thread.stepIn('instruction'));
492+
await getThreadAndRun(accessor, context, (thread: IThread) => thread.stepIn('instruction'));
493493
} else {
494-
getThreadAndRun(accessor, context, (thread: IThread) => thread.stepIn());
494+
await getThreadAndRun(accessor, context, (thread: IThread) => thread.stepIn());
495495
}
496496
}
497497
});
@@ -501,12 +501,12 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
501501
weight: KeybindingWeight.WorkbenchContrib,
502502
primary: KeyMod.Shift | KeyCode.F11,
503503
when: CONTEXT_DEBUG_STATE.isEqualTo('stopped'),
504-
handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
504+
handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
505505
const contextKeyService = accessor.get(IContextKeyService);
506506
if (CONTEXT_DISASSEMBLY_VIEW_FOCUS.getValue(contextKeyService)) {
507-
getThreadAndRun(accessor, context, (thread: IThread) => thread.stepOut('instruction'));
507+
await getThreadAndRun(accessor, context, (thread: IThread) => thread.stepOut('instruction'));
508508
} else {
509-
getThreadAndRun(accessor, context, (thread: IThread) => thread.stepOut());
509+
await getThreadAndRun(accessor, context, (thread: IThread) => thread.stepOut());
510510
}
511511
}
512512
});
@@ -516,8 +516,8 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
516516
weight: KeybindingWeight.WorkbenchContrib + 2, // take priority over focus next part while we are debugging
517517
primary: KeyCode.F6,
518518
when: CONTEXT_DEBUG_STATE.isEqualTo('running'),
519-
handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
520-
getThreadAndRun(accessor, context, thread => thread.pause());
519+
handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
520+
await getThreadAndRun(accessor, context, thread => thread.pause());
521521
}
522522
});
523523

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

657657
CommandsRegistry.registerCommand({
658658
id: SHOW_LOADED_SCRIPTS_ID,
659659
handler: async (accessor) => {
660-
661660
await showLoadedScriptMenu(accessor);
662-
663661
}
664662
});
665663

0 commit comments

Comments
 (0)