Skip to content

Commit ad185e2

Browse files
committed
activation menu item is moved to
'explorer/context' location
1 parent 10e9735 commit ad185e2

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@
5353
"main": "./out/extension.js",
5454
"contributes": {
5555
"menus": {
56-
"view/title": [
56+
"explorer/context": [
5757
{
5858
"command": "CodeViz.show",
59-
"when": "true"
59+
"when": "explorerResourceIsFolder",
60+
"group": "2_workspace"
6061
}
6162
]
6263
},

src/data/vscc_datasource.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ export class VSCCDataSource {
66
public date: String = '';
77
private _dataFolderUri: Uri;
88

9-
public constructor(wsUri: Uri) {
9+
public constructor(wsUri: Uri, targetDir: Uri) {
1010
this._dataFolderUri = Uri.joinPath(wsUri, '.VSCodeCounter');;
1111
this._selectDataSourceFolder(wsUri);
1212
this._readDataSource();
1313
}
1414

1515
private _selectDataSourceFolder(wsUri: Uri) {
1616
let result: {date: String, path: String}[] = [];
17-
let vsccFolder = Uri.joinPath(wsUri, '.VSCodeCounter');
1817
const fs = require('fs');
1918
const dirPath = fs.readdirSync(this._dataFolderUri.fsPath);
2019
dirPath.map((item: String) => {

src/extension.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,19 @@ export function activate(context: ExtensionContext) {
3333
CCVizzuPanel.export(folderPath);
3434
}
3535
});
36-
const showCommand = commands.registerCommand("CodeViz.show", () => {
36+
const showCommand = commands.registerCommand("CodeViz.show", (targetDir: Uri | undefined) => {
3737
let wsPath: Uri;
3838
workspace.workspaceFolders?.map((folder) => {
3939
if (wsPath == undefined)
4040
wsPath = folder.uri;
4141
});
42-
commands.executeCommand('extension.vscode-counter.countInWorkspace').then(() => {
42+
commands.executeCommand('extension.vscode-counter.countInDirectory', targetDir).then(() => {
4343
setTimeout(() => {
4444
CCVizzuPanel.render(context.extensionUri).then(() => {
4545
let source: VSCCDataSource;
46-
source = new VSCCDataSource(wsPath);
46+
if (targetDir == undefined)
47+
targetDir = wsPath;
48+
source = new VSCCDataSource(wsPath, targetDir);
4749
if (source.data != undefined) {
4850
let data = new VSCCDataPrep();
4951
data.makeDataTable(source.data);

0 commit comments

Comments
 (0)