vscode--add-async-and-await.md

 1+++
 2repository_url = "https://github.com/microsoft/vscode"
 3revision = "29e6da6efa2287aaa981635a475d425ff4fd5d5c"
 4+++
 5
 6## Edit History
 7
 8```diff
 9--- a/src/vs/workbench/contrib/debug/browser/debugCommands.ts
10+++ b/src/vs/workbench/contrib/debug/browser/debugCommands.ts
11@@ -304,8 +304,8 @@ CommandsRegistry.registerCommand({
12 
13 CommandsRegistry.registerCommand({
14 	id: REVERSE_CONTINUE_ID,
15-	handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
16-		getThreadAndRun(accessor, context, thread => thread.reverseContinue());
17+	handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
18+		await getThreadAndRun(accessor, context, thread => thread.reverseContinue());
19 	}
20 });
21--- a/src/vs/workbench/contrib/debug/browser/debugCommands.ts
22+++ b/src/vs/workbench/contrib/debug/browser/debugCommands.ts
23@@ -311,11 +311,11 @@ CommandsRegistry.registerCommand({
24 
25 CommandsRegistry.registerCommand({
26 	id: STEP_BACK_ID,
27-	handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
28+	handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
29 		const contextKeyService = accessor.get(IContextKeyService);
30 		if (CONTEXT_DISASSEMBLY_VIEW_FOCUS.getValue(contextKeyService)) {
31-			getThreadAndRun(accessor, context, (thread: IThread) => thread.stepBack('instruction'));
32+			await getThreadAndRun(accessor, context, (thread: IThread) => thread.stepBack('instruction'));
33 		} else {
34-			getThreadAndRun(accessor, context, (thread: IThread) => thread.stepBack());
35+			await getThreadAndRun(accessor, context, (thread: IThread) => thread.stepBack());
36 		}
37 	}
38 });
39--- a/src/vs/workbench/contrib/debug/browser/debugCommands.ts
40+++ b/src/vs/workbench/contrib/debug/browser/debugCommands.ts
41@@ -323,8 +323,8 @@ CommandsRegistry.registerCommand({
42 
43 CommandsRegistry.registerCommand({
44 	id: TERMINATE_THREAD_ID,
45-	handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
46-		getThreadAndRun(accessor, context, thread => thread.terminate());
47+	handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
48+		await getThreadAndRun(accessor, context, thread => thread.terminate());
49 	}
50 });
51```
52
53## Cursor Position
54
55```src/vs/workbench/contrib/debug/browser/debugCommands.ts
56	weight: KeybindingWeight.WorkbenchContrib,
57	primary: isWeb ? (KeyMod.Alt | KeyCode.F10) : KeyCode.F10, // Browsers do not allow F10 to be binded so we have to bind an alternative
58	when: CONTEXT_DEBUG_STATE.isEqualTo('stopped'),
59	handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
60	//       ^[CURSOR_POSITION]
61		const contextKeyService = accessor.get(IContextKeyService);
62		if (CONTEXT_DISASSEMBLY_VIEW_FOCUS.getValue(contextKeyService)) {
63			getThreadAndRun(accessor, context, (thread: IThread) => thread.next('instruction'));
64		} else {
65```
66
67## Expected Patch
68
69```diff
70--- a/src/vs/workbench/contrib/debug/browser/debugCommands.ts
71+++ b/src/vs/workbench/contrib/debug/browser/debugCommands.ts
72@@ -467,10 +467,10 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
73 	weight: KeybindingWeight.WorkbenchContrib,
74 	primary: isWeb ? (KeyMod.Alt | KeyCode.F10) : KeyCode.F10, // Browsers do not allow F10 to be binded so we have to bind an alternative
75 	when: CONTEXT_DEBUG_STATE.isEqualTo('stopped'),
76-	handler: (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
77+	handler: async (accessor: ServicesAccessor, _: string, context: CallStackContext | unknown) => {
78 		const contextKeyService = accessor.get(IContextKeyService);
79 		if (CONTEXT_DISASSEMBLY_VIEW_FOCUS.getValue(contextKeyService)) {
80-			getThreadAndRun(accessor, context, (thread: IThread) => thread.next('instruction'));
81+			await getThreadAndRun(accessor, context, (thread: IThread) => thread.next('instruction'));
82 		} else {
83-			getThreadAndRun(accessor, context, (thread: IThread) => thread.next());
84+			await getThreadAndRun(accessor, context, (thread: IThread) => thread.next());
85 		}
86 	}
87 });
88```