Skip to content

Commit bae3480

Browse files
author
Benjamin Pasero
committed
💄 - adopt some await for commands
1 parent ab1d1ad commit bae3480

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/vs/workbench/api/browser/mainThreadEditors.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
278278

279279
// --- commands
280280

281-
CommandsRegistry.registerCommand('_workbench.open', function (accessor: ServicesAccessor, args: [URI, IEditorOptions, EditorViewColumn, string?]) {
281+
CommandsRegistry.registerCommand('_workbench.open', async function (accessor: ServicesAccessor, args: [URI, IEditorOptions, EditorViewColumn, string?]) {
282282
const editorService = accessor.get(IEditorService);
283283
const editorGroupService = accessor.get(IEditorGroupsService);
284284
const openerService = accessor.get(IOpenerService);
@@ -287,16 +287,17 @@ CommandsRegistry.registerCommand('_workbench.open', function (accessor: Services
287287

288288
if (options || typeof position === 'number') {
289289
// use editor options or editor view column as a hint to use the editor service for opening
290-
return editorService.openEditor({ resource, options, label }, viewColumnToEditorGroup(editorGroupService, position)).then(_ => undefined);
290+
await editorService.openEditor({ resource, options, label }, viewColumnToEditorGroup(editorGroupService, position));
291+
return;
291292
}
292293

293294
if (resource && resource.scheme === 'command') {
294295
// do not allow to execute commands from here
295-
return Promise.resolve(undefined);
296+
return;
296297

297298
}
298299
// finally, delegate to opener service
299-
return openerService.open(resource).then(_ => undefined);
300+
await openerService.open(resource);
300301
});
301302

302303
CommandsRegistry.registerCommand('_workbench.openWith', (accessor: ServicesAccessor, args: [URI, string, ITextEditorOptions | undefined, EditorViewColumn | undefined]) => {
@@ -315,7 +316,7 @@ CommandsRegistry.registerCommand('_workbench.openWith', (accessor: ServicesAcces
315316
});
316317

317318

318-
CommandsRegistry.registerCommand('_workbench.diff', function (accessor: ServicesAccessor, args: [URI, URI, string, string, IEditorOptions, EditorViewColumn]) {
319+
CommandsRegistry.registerCommand('_workbench.diff', async function (accessor: ServicesAccessor, args: [URI, URI, string, string, IEditorOptions, EditorViewColumn]) {
319320
const editorService = accessor.get(IEditorService);
320321
const editorGroupService = accessor.get(IEditorGroupsService);
321322

@@ -331,17 +332,17 @@ CommandsRegistry.registerCommand('_workbench.diff', function (accessor: Services
331332
label = localize('diffLeftRightLabel', "{0} ⟷ {1}", leftResource.toString(true), rightResource.toString(true));
332333
}
333334

334-
return editorService.openEditor({ leftResource, rightResource, label, description, options }, viewColumnToEditorGroup(editorGroupService, position)).then(() => undefined);
335+
await editorService.openEditor({ leftResource, rightResource, label, description, options }, viewColumnToEditorGroup(editorGroupService, position));
335336
});
336337

337-
CommandsRegistry.registerCommand('_workbench.revertAllDirty', (accessor: ServicesAccessor) => {
338+
CommandsRegistry.registerCommand('_workbench.revertAllDirty', async function (accessor: ServicesAccessor) {
338339
const environmentService = accessor.get(IEnvironmentService);
339340
if (!environmentService.extensionTestsLocationURI) {
340341
throw new Error('Command is only available when running extension tests.');
341342
}
342343

343344
const workingCopyService = accessor.get(IWorkingCopyService);
344345
for (const workingCopy of workingCopyService.dirtyWorkingCopies) {
345-
workingCopy.revert({ soft: true });
346+
await workingCopy.revert({ soft: true });
346347
}
347348
});

0 commit comments

Comments
 (0)