Merge pull request #2426 from github/robertbrignull/open-on-click
Open query file on click
This commit is contained in:
@@ -17,11 +17,18 @@ export class QueryTreeDataProvider
|
||||
private createTree(): QueryTreeViewItem[] {
|
||||
// Temporary mock data, just to populate the tree view.
|
||||
return [
|
||||
new QueryTreeViewItem("name1", "path1", []),
|
||||
new QueryTreeViewItem("name2", "path2", [
|
||||
new QueryTreeViewItem("name3", "path3", []),
|
||||
new QueryTreeViewItem("name4", "path4", [
|
||||
new QueryTreeViewItem("name5", "path5", []),
|
||||
new QueryTreeViewItem("custom-pack", [
|
||||
new QueryTreeViewItem("custom-pack/example.ql", []),
|
||||
]),
|
||||
new QueryTreeViewItem("ql", [
|
||||
new QueryTreeViewItem("ql/javascript", [
|
||||
new QueryTreeViewItem("ql/javascript/example.ql", []),
|
||||
]),
|
||||
new QueryTreeViewItem("ql/go", [
|
||||
new QueryTreeViewItem("ql/go/security", [
|
||||
new QueryTreeViewItem("ql/go/security/query1.ql", []),
|
||||
new QueryTreeViewItem("ql/go/security/query2.ql", []),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
];
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
import * as vscode from "vscode";
|
||||
import { basename } from "path";
|
||||
|
||||
export class QueryTreeViewItem extends vscode.TreeItem {
|
||||
constructor(
|
||||
label: string,
|
||||
tooltip: string | undefined,
|
||||
public readonly children: QueryTreeViewItem[],
|
||||
) {
|
||||
super(label);
|
||||
this.tooltip = tooltip;
|
||||
constructor(path: string, public readonly children: QueryTreeViewItem[]) {
|
||||
super(basename(path));
|
||||
this.tooltip = path;
|
||||
this.collapsibleState = this.children.length
|
||||
? vscode.TreeItemCollapsibleState.Collapsed
|
||||
: vscode.TreeItemCollapsibleState.None;
|
||||
if (this.children.length === 0) {
|
||||
this.command = {
|
||||
title: "Open",
|
||||
command: "vscode.open",
|
||||
arguments: [vscode.Uri.file(path)],
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user