Add ability to continue desktop edit session in vscode.dev

This commit is contained in:
Joyce Er 2022-07-15 15:51:51 -07:00
parent 425a6dec81
commit 73b34320c1
No known key found for this signature in database
GPG key ID: A15311FAE9EC8CD6
2 changed files with 34 additions and 5 deletions

View file

@ -26,7 +26,8 @@
}
},
"enabledApiProposals": [
"contribShareMenu"
"contribShareMenu",
"contribEditSessions"
],
"contributes": {
"commands": [
@ -37,10 +38,20 @@
{
"command": "github.copyVscodeDevLink",
"title": "Copy vscode.dev Link"
},
{
"command": "github.copyVscodeDevLinkFile",
"title": "Copy vscode.dev Link"
},
{
"command": "github.copyVscodeDevLinkFile",
"title": "Copy vscode.dev Link"
},
{
"command": "github.openOnVscodeDev",
"title": "Open on vscode.dev"
}
],
"continueEditSession": [
{
"command": "github.openOnVscodeDev",
"when": "github.hasGitHubRepo"
}
],
"menus": {
@ -56,6 +67,10 @@
{
"command": "github.copyVscodeDevLinkFile",
"when": "false"
},
{
"command": "github.openOnVscodeDev",
"when": "false"
}
],
"file/share": [

View file

@ -20,6 +20,16 @@ async function copyVscodeDevLink(gitAPI: GitAPI, useSelection: boolean) {
}
}
async function openVscodeDevLink(gitAPI: GitAPI): Promise<vscode.Uri | undefined> {
try {
const permalink = getPermalink(gitAPI, true, 'https://vscode.dev/github');
return permalink ? vscode.Uri.parse(permalink) : undefined;
} catch (err) {
vscode.window.showErrorMessage(err.message);
return undefined;
}
}
export function registerCommands(gitAPI: GitAPI): vscode.Disposable {
const disposables = new DisposableStore();
@ -39,5 +49,9 @@ export function registerCommands(gitAPI: GitAPI): vscode.Disposable {
return copyVscodeDevLink(gitAPI, false);
}));
disposables.add(vscode.commands.registerCommand('github.openOnVscodeDev', async () => {
return openVscodeDevLink(gitAPI);
}));
return disposables;
}