Skip to content

Commit

Permalink
Merge pull request #155352 from microsoft/dev/joyceerhl/total-toucan
Browse files Browse the repository at this point in the history
Add ability to continue desktop edit session in vscode.dev
  • Loading branch information
joyceerhl authored Jul 17, 2022
2 parents 7839742 + 598e4be commit 0ea3709
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
25 changes: 20 additions & 5 deletions extensions/github/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
}
},
"enabledApiProposals": [
"contribShareMenu"
"contribShareMenu",
"contribEditSessions"
],
"contributes": {
"commands": [
Expand All @@ -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": {
Expand All @@ -56,6 +67,10 @@
{
"command": "github.copyVscodeDevLinkFile",
"when": "false"
},
{
"command": "github.openOnVscodeDev",
"when": "false"
}
],
"file/share": [
Expand Down
14 changes: 14 additions & 0 deletions extensions/github/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class EditSessionsContribution extends Disposable implements IWorkbenchCo
}
const commands = new Map((extension.description.contributes?.commands ?? []).map(c => [c.command, c]));
for (const contribution of extension.value) {
if (!contribution.command || !contribution.group || !contribution.when) {
if (!contribution.command || !contribution.when) {
continue;
}
const fullCommand = commands.get(contribution.command);
Expand Down

0 comments on commit 0ea3709

Please sign in to comment.