Skip to content

Commit 5be7fb7

Browse files
committed
Polish
1 parent fed69c3 commit 5be7fb7

File tree

7 files changed

+82
-49
lines changed

7 files changed

+82
-49
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66

77
It's not too smart yet, but:
88

9-
- it lets you choose a test file and re-run that file easily from anywhere in your editor.
10-
- It adds syntax highlighting for .types and .symbol files in a way which won't fill your screen with errors.
9+
### Syntax Highlighting for Test Files
1110

12-
- Symbol files ![](./screenshots/symbols.png)
11+
- Symbol files ![](./screenshots/symbols.png)
12+
- Type Files ![](./screenshots/types.png)
1313

14-
- Type Files ![](./screenshots/types.png)
14+
### Changed Baselines Info
1515

16-
### For more information
16+
Shows up to 100 changed baselines with:
1717

18-
- [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown)
19-
- [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/)
18+
- Jump to local/reference
19+
- Show diff
20+
- Jump to test (most of the time)
2021

21-
**Enjoy!**
22+
Has a button for `gulp diff`.

package.json

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,35 @@
7171
"command": "tsDev.openReferenceShort",
7272
"when": "view == tsDev.baselines && viewItem == edited",
7373
"group": "inline"
74+
},
75+
{
76+
"command": "tsDev.openDiffShort",
77+
"when": "view == tsDev.baselines && viewItem == edited",
78+
"group": "inline"
79+
},
80+
{
81+
"command": "tsDev.openTestShort",
82+
"when": "view == tsDev.baselines && viewItem == edited"
83+
},
84+
{
85+
"command": "tsDev.openReferenceShort",
86+
"when": "view == tsDev.baselines && viewItem == edited"
87+
},
88+
{
89+
"command": "tsDev.openDiffShort",
90+
"when": "view == tsDev.baselines && viewItem == edited"
91+
},
92+
{
93+
"command": "tsDev.copyPath",
94+
"when": "view == tsDev.baselines && viewItem == edited"
7495
}
7596
]
7697
},
7798
"commands": [
7899
{
79100
"command": "tsDev.openDiffTool",
80101
"title": "Difftool",
81-
"shortTitle": "Difftool"
102+
"shortTitle": "Gulp Diff"
82103
},
83104
{
84105
"command": "tsDev.openTestShort",
@@ -87,6 +108,14 @@
87108
{
88109
"command": "tsDev.openReferenceShort",
89110
"title": "Ref"
111+
},
112+
{
113+
"command": "tsDev.openDiffShort",
114+
"title": "Diff"
115+
},
116+
{
117+
"command": "tsDev.copyPath",
118+
"title": "Copy Path"
90119
}
91120
]
92121
},

src/baselineToTest.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ describe("edge cases", () => {
4242
"/tests/baselines/local/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/multiple-prologues-in-all-projects.js",
4343
"/src/testRunner/unittests/tsbuild/amdModulesWithOut.ts:85",
4444
],
45-
// [
46-
// "/tests/baselines/local/tsbuild/outfile-concat/incremental-headers-change-without-dts-changes/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js",
47-
// "/src/testRunner/unittests/tsbuild/amdModulesWithOut.ts:85",
48-
// ],
4945
];
5046
for (const test of tests) {
5147
expect(baseLineToTest(root + test[0])).toEqual(root + test[1]);

src/baselineToTest.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { join, parse, sep } from "path";
2-
import * as os from "os";
32
import * as fs from "fs";
43

54
export const baselineToTester = (config: { tscRoot: string }) => {
@@ -75,18 +74,19 @@ export const baselineToTester = (config: { tscRoot: string }) => {
7574
}
7675
}
7776

78-
// Known pattern lookups like the tsbuild one
77+
// Known pattern lookups:
7978

8079
// With tsbuild files, the names are pretty auto-generated
8180
if (components[4] === "tsbuild") {
8281
const tsBuildTests = join(config.tscRoot, "src", "testRunner", "unittests", "tsbuild");
8382
const filesInDirectory = fs.readdirSync(tsBuildTests);
84-
// Look through all the tsbuild test files
85-
const scenario = `subscenario: "${name.replace(/-/g, " ")}",`;
86-
console.log(scenario);
83+
84+
// Look through all the tsbuild test files, looking for a sub-scenario with the same name as the file
85+
const scenario = `subscenario: "${name.replace(/-/g, " ")}"`.toLowerCase();
86+
8787
for (const f of filesInDirectory) {
8888
const filepath = join(tsBuildTests, f);
89-
const content = fs.readFileSync(filepath, "utf8").toLowerCase().replace(/-/g, " ");
89+
const content = fs.readFileSync(filepath, "utf8").toLowerCase();
9090

9191
if (content.includes(scenario)) {
9292
const line = getLineForResultInString(scenario, content);

src/baselines.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ export class BaselinesProvider implements vscode.TreeDataProvider<TreeNode> {
6666

6767
treeItem.command = {
6868
command: "vscode.open",
69-
title: `Open new file`,
69+
title: `Open changed file`,
7070
arguments: [node.uri],
7171
};
7272

73-
treeItem.contextValue = "edited"
73+
treeItem.contextValue = "edited";
74+
treeItem.resourceUri = node.uri;
7475
return treeItem;
7576
}
7677
}

src/extension.ts

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import * as vscode from "vscode";
22
import { BaselinesProvider, TreeNode } from "./baselines";
3-
import { showBaselineDiff } from "./showBaselineDiff";
43
import { createBaselineFinder } from "./baselineFinder";
54
import { baselineToTester } from "./baselineToTest";
65

6+
// https://code.visualstudio.com/api/references/commands
7+
78
export function activate(context: vscode.ExtensionContext) {
89
const workspace = vscode.workspace.workspaceFolders![0];
910
const watcher = createBaselineFinder(workspace.uri.fsPath);
@@ -12,25 +13,46 @@ export function activate(context: vscode.ExtensionContext) {
1213
const baselinesProvider = new BaselinesProvider(watcher.resultsEmitter);
1314
vscode.window.registerTreeDataProvider("tsDev.baselines", baselinesProvider);
1415

15-
let disposable = vscode.commands.registerCommand("io.orta.typescript-dev.show-baseline-diff", showBaselineDiff);
16-
context.subscriptions.push(disposable);
16+
const getTest = baselineToTester({ tscRoot: workspace.uri.fsPath });
1717

18-
let cmd1 = vscode.commands.registerCommand("tsDev.openReferenceShort", (item: TreeNode) => {
18+
const diffTool = vscode.commands.registerCommand("tsDev.openDiffTool", () => {
19+
require("child_process").exec("gulp diff");
20+
});
21+
22+
const open = vscode.commands.registerCommand("tsDev.openReferenceShort", (item: TreeNode) => {
1923
vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(item.uri.fsPath.replace("local", "reference")));
2024
});
2125

22-
const getTest = baselineToTester({ tscRoot: workspace.uri.fsPath });
26+
const diff = vscode.commands.registerCommand("tsDev.openDiffShort", (item: TreeNode) => {
27+
const local = vscode.Uri.parse(item.uri.fsPath);
28+
const ref = vscode.Uri.parse(item.uri.fsPath.replace("local", "reference"));
29+
vscode.commands.executeCommand("vscode.diff", local, ref, `Diff for ${item.display}`);
30+
});
2331

24-
let cmd2 = vscode.commands.registerCommand("tsDev.openTestShort", (item: TreeNode) => {
32+
const test = vscode.commands.registerCommand("tsDev.openTestShort", (item: TreeNode) => {
2533
const testFile = getTest(item.uri.fsPath);
2634
if (!testFile) {
27-
vscode.window.showErrorMessage(`Could not find a test file for ${item.uri.fsPath}`);
35+
vscode.window.showErrorMessage(`Could not find a test file for ${item.uri.fsPath}`, "Copy Local Path").then((res) => {
36+
if (res && res.length) {
37+
vscode.env.clipboard.writeText(item.uri.fsPath);
38+
vscode.window.showInformationMessage("Copied");
39+
}
40+
});
2841
} else {
29-
// const [path, number] = testFile.split(":")[0];
30-
// const meta: vscode.TextDocumentShowOptions = ;
31-
// const d = vscode.window.showTextDocument();
32-
vscode.commands.executeCommand("vscode.open", "file:/" + vscode.Uri.parse(testFile));
42+
const [path, line] = testFile.split(":");
43+
const opts: vscode.TextDocumentShowOptions = line
44+
? {
45+
selection: new vscode.Range(new vscode.Position(Number(line), 0), new vscode.Position(Number(line), 0)),
46+
}
47+
: {};
48+
vscode.commands.executeCommand("vscode.open", vscode.Uri.parse(path), opts);
3349
}
3450
});
35-
context.subscriptions.push(cmd2);
51+
52+
const copy = vscode.commands.registerCommand("tsDev.copyPath", (item: TreeNode) => {
53+
vscode.env.clipboard.writeText(item.uri.fsPath);
54+
vscode.window.showInformationMessage("Copied");
55+
});
56+
57+
context.subscriptions.push(open, test, diff, copy, diffTool);
3658
}

src/showBaselineDiff.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)