Skip to content

Commit 0940267

Browse files
Added vscode explorer context menu alternative for running filecheck command
1 parent 74e757c commit 0940267

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Extension for handling [Coverlet](https://github.com/tonerdo/coverlet) reports o
1616

1717
- Run `Coverlet Strip` on an opened `coverlet.json` report file to strip it from everything that is already tested.
1818

19-
- Run `Coverlet Filecheck` on an opened C# class file to open a coverlet report with reports for only that file.
19+
- Run `Coverlet Filecheck` on an opened C# class file to show the existing report contents regarding the file. Alternatively, you can right-click the file on vscode explorer and run the filecheck command. The result will show both tested and untested lines for the file.
2020

2121
## Debugging the extension source
2222

@@ -30,15 +30,17 @@ Extension for handling [Coverlet](https://github.com/tonerdo/coverlet) reports o
3030

3131
- A test instance of vscode loaded with the extension will appear
3232

33+
- Extra: you can also run unit tests for the extension by executing `npm test` on terminal
34+
3335
## Release Notes
3436

3537
### 1.1.0
3638

37-
- Added `Filecheck` command
39+
- Added Filecheck command
3840

3941
### 1.0.1
4042

41-
- Fix bug that leaves null values while removing some branches
43+
- Fixed bug that leaved null values while removing some branches
4244

4345
### 1.0.0
4446

package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
],
2525
"activationEvents": [
2626
"onCommand:extension.coverletStrip",
27-
"onCommand:extension.coverletFilecheck"
27+
"onCommand:extension.coverletFilecheck",
28+
"onCommand:extension.coverletFilecheckMenu"
2829
],
2930
"main": "./out/extension",
3031
"contributes": {
@@ -36,8 +37,19 @@
3637
{
3738
"command": "extension.coverletFilecheck",
3839
"title": "Coverlet Filecheck"
40+
},
41+
{
42+
"command": "extension.coverletFilecheckMenu",
43+
"title": "Coverlet Filecheck"
3944
}
40-
]
45+
],
46+
"menus": {
47+
"explorer/context": [{
48+
"when": "resourceLangId == csharp",
49+
"command": "extension.coverletFilecheckMenu",
50+
"group": "z_commands"
51+
}]
52+
}
4153
},
4254
"scripts": {
4355
"vscode:prepublish": "npm run compile",

src/extension.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as strip from './strip';
66
export function activate(context: vscode.ExtensionContext) {
77
context.subscriptions.push(vscode.commands.registerCommand('extension.coverletStrip', coverletStripHandler));
88
context.subscriptions.push(vscode.commands.registerCommand('extension.coverletFilecheck', coverletFilecheckHandler));
9+
context.subscriptions.push(vscode.commands.registerCommand('extension.coverletFilecheckMenu', coverletFilecheckMenuHandler));
910
}
1011

1112
export function coverletStripHandler() {
@@ -41,15 +42,18 @@ export function coverletFilecheckHandler() {
4142
if(vscode.workspace == undefined)
4243
return;
4344

44-
//Get filename of the current file
45-
let editor = vscode.window.activeTextEditor;
46-
47-
if(!editor)
45+
// An editor must be opened
46+
if(!vscode.window.activeTextEditor)
4847
return;
4948

50-
var classFilename = "";
51-
classFilename = editor.document.fileName;
49+
filecheck(vscode.window.activeTextEditor.document.fileName);
50+
}
51+
52+
export function coverletFilecheckMenuHandler(uri:vscode.Uri) {
53+
filecheck(uri.fsPath);
54+
};
5255

56+
export function filecheck(classFilename : string) {
5357
//Find a coverlet report file
5458
vscode.workspace.findFiles('*/coverage.json', '**/node_modules/**', 1).then((uris) => {
5559
uris.forEach((uri) => {

0 commit comments

Comments
 (0)