Skip to content

Commit fcae65b

Browse files
committed
Update 0.0.2
1 parent 4c98746 commit fcae65b

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

src/extension.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
import { exec } from 'child_process';
44
import { quote } from 'shell-quote';
5-
import { window, commands, ExtensionContext, workspace, Selection } from 'vscode';
5+
import { window, commands, ExtensionContext, workspace, Selection, QuickPickItem, QuickPickOptions } from 'vscode';
6+
7+
interface QuickPickItemWithPath extends QuickPickItem {
8+
fullpath?: string;
9+
}
610

711
const projectRoot = workspace.rootPath ? workspace.rootPath : '.';
812

@@ -18,12 +22,31 @@ export function activate(context: ExtensionContext) {
1822
window.showErrorMessage(stderr);
1923
return Promise.resolve();
2024
}
21-
const lines = stdout.split(/\n/);
22-
if (lines.length === 1 && lines[0] === '') {
25+
const lines = stdout.split(/\n/).filter(l => l !== '');
26+
const items: QuickPickItemWithPath[] = lines.map(l => {
27+
const [fullPath, line, desc] = l.split(':');
28+
const path = fullPath.split('/');
29+
return {
30+
label: `${path[path.length - 1]} : ${line}`,
31+
description: desc,
32+
fullPath: l,
33+
};
34+
});
35+
if (!lines.length) {
2336
window.showInformationMessage('There are no items')
2437
return Promise.resolve();
2538
}
26-
const [file, line] = (await window.showQuickPick(lines)).split(':');
39+
let item;
40+
try {
41+
const options: QuickPickOptions = {
42+
matchOnDescription: true,
43+
}
44+
item = await window.showQuickPick(items, options);
45+
} catch (e) {
46+
window.showErrorMessage(e);
47+
}
48+
49+
const [file, line] = item.fullPath.split(':');
2750
const doc = await workspace.openTextDocument(projectRoot + '/' + file);
2851
await window.showTextDocument(doc);
2952
window.activeTextEditor.selection = new Selection(~~line, 0, ~~line, 0);

0 commit comments

Comments
 (0)