Skip to content

Commit d41b079

Browse files
Allow 1-based step numbers via URI Handler
1 parent 7ae9935 commit d41b079

File tree

3 files changed

+16
-24
lines changed

3 files changed

+16
-24
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
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.56
8+
9+
- URI handler now allows specifying the step via 1-based numbers, as opposed to 0-based
10+
711
## v0.0.55
812

913
- The URI handler now allows specifying _just_ a step number, in order to index into a repo within only a single tour

package.json

Lines changed: 1 addition & 1 deletion
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.55",
6+
"version": "0.0.56",
77
"author": {
88
"name": "Microsoft Corporation"
99
},

src/extension.ts

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,19 @@ function startTour(params: URLSearchParams) {
2929
let tourPath = params.get("tour");
3030
const step = params.get("step");
3131

32-
console.log("CT Tour: ", tourPath);
33-
console.log("CT Step: ", step);
34-
3532
let stepNumber;
3633
if (step) {
37-
stepNumber = Number(step);
34+
// Allow the step number to be
35+
// provided as 1-based vs. 0-based
36+
stepNumber = Number(step) - 1;
3837
}
3938

4039
if (tourPath) {
4140
if (!tourPath.endsWith(".tour")) {
4241
tourPath = `${tourPath}.tour`;
4342
}
4443

45-
console.log("CT Tour Path: ", tourPath);
46-
47-
console.log("CT Tours: ", store.tours);
48-
4944
const tour = store.tours.find(tour => tour.id.endsWith(tourPath as string));
50-
51-
console.log("CT Tour: ", tour);
52-
5345
if (tour) {
5446
startCodeTour(tour, stepNumber);
5547
}
@@ -68,20 +60,16 @@ class URIHandler implements vscode.UriHandler {
6860
this._didStartDefaultTour = true;
6961
await discoverTours();
7062

63+
let query = uri.query;
7164
if (uri.path === "/startDefaultTour") {
72-
if (uri.query) {
73-
console.log("CT Query: ", uri.query);
74-
try {
75-
const origin = vscode.Uri.parse(uri.query);
76-
if (origin.query) {
77-
const params = new URLSearchParams(origin.query);
78-
startTour(params);
79-
}
80-
} catch {}
81-
}
82-
} else if (uri.path === "/starTour") {
83-
const params = new URLSearchParams(uri.query);
65+
query = vscode.Uri.parse(uri.query).query;
66+
}
67+
68+
if (query) {
69+
const params = new URLSearchParams(query);
8470
startTour(params);
71+
} else {
72+
startDefaultTour();
8573
}
8674
}
8775
}

0 commit comments

Comments
 (0)