forked from gurgeous/bust-a-gem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopen.ts
32 lines (28 loc) · 854 Bytes
/
open.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import * as vscode from 'vscode';
import { Gem } from './gem';
//
// Open Gem entry point. This is a try/catch wrapper around open0.
//
export const open = async () => {
try {
await open0();
} catch (error) {
console.error(error);
vscode.window.showErrorMessage(`Bust-A-Gem: ${error.message}`);
}
};
const open0 = async () => {
// load gems, turn into QuickPickItems
const gems = await Gem.list();
const items = gems.map(gem => {
return { label: gem.label, description: '', dir: gem.dir };
});
// show quick picks, then open that folder
const options = { placeHolder: 'Select a gem to open' };
const selection = await vscode.window.showQuickPick(items, options);
if (!selection) {
return;
}
const uri = vscode.Uri.file(selection.dir);
vscode.commands.executeCommand('vscode.openFolder', uri, true);
};