Allow 1-based step numbers via URI Handler

This commit is contained in:
Jonathan Carter 2021-05-29 20:58:40 +00:00 коммит произвёл GitHub
Родитель 7ae9935bbe
Коммит d41b079f1f
3 изменённых файлов: 16 добавлений и 24 удалений

Просмотреть файл

@ -4,6 +4,10 @@
- Automatically set the "pattern" record mode when you create a new tour, and select `None` for the git ref
- Added support for opening a `*.tour` file in the VS Code notebook editor (Insiders only)
## v0.0.56
- URI handler now allows specifying the step via 1-based numbers, as opposed to 0-based
## v0.0.55
- The URI handler now allows specifying _just_ a step number, in order to index into a repo within only a single tour

Просмотреть файл

@ -3,7 +3,7 @@
"displayName": "CodeTour",
"description": "VS Code extension that allows you to record and playback guided tours of codebases, directly within the editor",
"publisher": "vsls-contrib",
"version": "0.0.55",
"version": "0.0.56",
"author": {
"name": "Microsoft Corporation"
},

Просмотреть файл

@ -29,12 +29,11 @@ function startTour(params: URLSearchParams) {
let tourPath = params.get("tour");
const step = params.get("step");
console.log("CT Tour: ", tourPath);
console.log("CT Step: ", step);
let stepNumber;
if (step) {
stepNumber = Number(step);
// Allow the step number to be
// provided as 1-based vs. 0-based
stepNumber = Number(step) - 1;
}
if (tourPath) {
@ -42,14 +41,7 @@ function startTour(params: URLSearchParams) {
tourPath = `${tourPath}.tour`;
}
console.log("CT Tour Path: ", tourPath);
console.log("CT Tours: ", store.tours);
const tour = store.tours.find(tour => tour.id.endsWith(tourPath as string));
console.log("CT Tour: ", tour);
if (tour) {
startCodeTour(tour, stepNumber);
}
@ -68,20 +60,16 @@ class URIHandler implements vscode.UriHandler {
this._didStartDefaultTour = true;
await discoverTours();
let query = uri.query;
if (uri.path === "/startDefaultTour") {
if (uri.query) {
console.log("CT Query: ", uri.query);
try {
const origin = vscode.Uri.parse(uri.query);
if (origin.query) {
const params = new URLSearchParams(origin.query);
startTour(params);
}
} catch {}
}
} else if (uri.path === "/starTour") {
const params = new URLSearchParams(uri.query);
query = vscode.Uri.parse(uri.query).query;
}
if (query) {
const params = new URLSearchParams(query);
startTour(params);
} else {
startDefaultTour();
}
}
}