Skip to content

Commit 7cb72be

Browse files
Fixing misc. bugs
1 parent 1876e21 commit 7cb72be

File tree

5 files changed

+58
-30
lines changed

5 files changed

+58
-30
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
- Automatically set the "pattern" record mode when you create a new tour, and select `None` for the git ref
55
- Added support for opening a `*.tour` file in the VS Code notebook editor (Insiders only)
66

7+
## v0.0.59 (03/24/2022)
8+
9+
- Tours are now written to the `CodeTour: Custom Tour Directory` directory, when that property is set
10+
- Fixed a performance issue with large codebases
11+
712
## v0.0.58 (07/08/2021)
813

914
- The "Tours available!" prompt is now suppressed when opening a [CodeSwing](https://aka.ms/codeswing) workspace

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "CodeTour",
44
"description": "VS Code extension that allows you to record and playback guided tours of codebases, directly within the editor",
55
"publisher": "vsls-contrib",
6-
"version": "0.0.58",
6+
"version": "0.0.59",
77
"author": {
88
"name": "Microsoft Corporation"
99
},
@@ -18,7 +18,7 @@
1818
"license": "MIT",
1919
"icon": "images/icon.png",
2020
"engines": {
21-
"vscode": "^1.48.0"
21+
"vscode": "^1.60.0"
2222
},
2323
"categories": [
2424
"Other"
@@ -31,7 +31,8 @@
3131
"workspace"
3232
],
3333
"activationEvents": [
34-
"*",
34+
"onStartupFinished",
35+
"onView:codetour.tours",
3536
"onNotebookEditor:codetour"
3637
],
3738
"main": "./dist/extension-node.js",
@@ -651,7 +652,7 @@
651652
"@types/axios": "^0.14.0",
652653
"@types/node": "^8.10.66",
653654
"@types/throttle-debounce": "^2.1.0",
654-
"@types/vscode": "~1.48.0",
655+
"@types/vscode": "^1.60.0",
655656
"ts-loader": "^7.0.4",
656657
"tslint": "^5.8.0",
657658
"typescript": "^3.1.4",

src/notebook/index.ts

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ import { CodeTour } from "../store";
77
import { getStepFileUri, getWorkspaceUri } from "../utils";
88

99
class CodeTourNotebookProvider implements vscode.NotebookSerializer {
10-
originalContent: Uint8Array = new TextEncoder().encode('');
10+
originalContent: Uint8Array = new TextEncoder().encode("");
1111

12-
async deserializeNotebook(content: Uint8Array, token: any): Promise<vscode.NotebookData> {
12+
async deserializeNotebook(
13+
content: Uint8Array,
14+
token: any
15+
): Promise<vscode.NotebookData> {
1316
this.originalContent = content;
1417
let contents = new TextDecoder().decode(content);
1518

@@ -21,8 +24,8 @@ class CodeTourNotebookProvider implements vscode.NotebookSerializer {
2124
const uri = await getStepFileUri(item, workspaceRoot, tour.ref);
2225
const document = await vscode.workspace.openTextDocument(uri);
2326

24-
const startLine = (item.line! > 10) ? item.line! - 10 : 0;
25-
const endLine = (item.line! > 1) ? item.line! - 1 : 0;
27+
const startLine = item.line! > 10 ? item.line! - 10 : 0;
28+
const endLine = item.line! > 1 ? item.line! - 1 : 0;
2629
const contents = document.getText(
2730
new vscode.Range(
2831
new vscode.Position(startLine, 0),
@@ -40,24 +43,39 @@ class CodeTourNotebookProvider implements vscode.NotebookSerializer {
4043
let cells: vscode.NotebookCellData[] = [];
4144

4245
// Title cell
43-
cells.push(new vscode.NotebookCellData(1,
44-
`## ![Icon](${SMALL_ICON_URL})&nbsp;&nbsp; CodeTour (${tour.title}) - ${steps.length} steps\n\n${tour.description === undefined ? '' : tour.description}`,
45-
'markdown'))
46+
cells.push(
47+
new vscode.NotebookCellData(
48+
1,
49+
`## ![Icon](${SMALL_ICON_URL})&nbsp;&nbsp; CodeTour (${tour.title}) - ${
50+
steps.length
51+
} steps\n\n${tour.description === undefined ? "" : tour.description}`,
52+
"markdown"
53+
)
54+
);
4655

4756
steps.forEach((step, index) => {
48-
cells.push(new vscode.NotebookCellData(2,
49-
step.contents,
50-
step.language,
51-
[new vscode.NotebookCellOutput([
52-
new vscode.NotebookCellOutputItem('text/markdown', `_Step #${index + 1} of ${steps.length}:_ ${step.description} ([View File](${step.uri}))`)
53-
])]
54-
))
55-
})
57+
const cell = new vscode.NotebookCellData(2, step.contents, step.language);
58+
cell.outputs = [
59+
new vscode.NotebookCellOutput([
60+
new vscode.NotebookCellOutputItem(
61+
new TextEncoder().encode(
62+
`_Step #${index + 1} of ${steps.length}:_ ${
63+
step.description
64+
} ([View File](${step.uri}))`
65+
),
66+
"text/markdown"
67+
)
68+
])
69+
];
70+
});
5671

57-
return new vscode.NotebookData(cells, new vscode.NotebookDocumentMetadata(true))
72+
return new vscode.NotebookData(cells);
5873
}
5974

60-
async serializeNotebook(data: vscode.NotebookData, token: any): Promise<Uint8Array> {
75+
async serializeNotebook(
76+
data: vscode.NotebookData,
77+
token: any
78+
): Promise<Uint8Array> {
6179
return this.originalContent;
6280
}
6381
}

src/recorder/commands.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,19 @@ export function registerRecorderCommands() {
4343
const file = title
4444
.toLocaleLowerCase()
4545
.replace(/\s/g, "-")
46-
.replace(/[^\w\d-_]/g, "");
46+
.replace(/[^\w\d\-_]/g, "");
4747

4848
const prefix = workspaceRoot.path.endsWith("/")
4949
? workspaceRoot.path
5050
: `${workspaceRoot.path}/`;
5151

52+
const customTourDirectory = vscode.workspace
53+
.getConfiguration(EXTENSION_NAME)
54+
.get("customTourDirectory", null);
55+
const tourDirectory = customTourDirectory || ".tours";
56+
5257
return workspaceRoot.with({
53-
path: `${prefix}.tours/${file}.tour`
58+
path: `${prefix}${tourDirectory}/${file}.tour`
5459
});
5560
}
5661

@@ -257,9 +262,8 @@ export function registerRecorderCommands() {
257262
}
258263
};
259264

260-
const previousStep = store.activeTour!.tour.steps[
261-
store.activeTour!.step - 1
262-
];
265+
const previousStep =
266+
store.activeTour!.tour.steps[store.activeTour!.step - 1];
263267

264268
// Check whether the end-user forgot to "reset"
265269
// the selection from the previous step, and if so,

0 commit comments

Comments
 (0)