Skip to content

Commit

Permalink
feat(vscode): make participant id copy-able
Browse files Browse the repository at this point in the history
  • Loading branch information
nedpals committed Mar 20, 2024
1 parent 8ff269e commit 786194f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions vscode-bugbuddy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
"command": "bugbuddy.run",
"title": "BugBuddy: Run File / Project",
"icon": "$(play)"
},
{
"command": "bugbuddy.copyParticipantId",
"title": "BugBuddy: Copy Participant ID"
}
],
"keybindings": [
Expand Down
17 changes: 16 additions & 1 deletion vscode-bugbuddy/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { join as joinWin32 } from "path/win32";
import { join as joinPosix } from "path/posix";
import { homedir } from "os";
import { ChildProcessWithoutNullStreams, spawn } from "child_process";
import { commands, window } from "vscode";
import { commands, env, window } from "vscode";
import { LanguageClient, LanguageClientOptions, ServerOptions } from "vscode-languageclient/node";
import { ConnectionStatus, extensionId, getWorkspaceConfig, openExplorerIn, outputChannel, setConnectionStatus } from "./utils";

Expand Down Expand Up @@ -222,6 +222,10 @@ export async function showServerMenu() {
}
});
break;
default:
if (picked?.startsWith('Participant ID: ')) {
await copyParticipantId();
}
}
}
}
Expand All @@ -243,3 +247,14 @@ export async function generateParticipantId() {
setConnectionStatus(ConnectionStatus.connected, { participantId: got.participant_id });
window.showInformationMessage('A new participant ID has been generated.');
}

export async function copyParticipantId() {
const participantId = await getParticipantId();
if (participantId === 'unknown') {
// Do not continue if participant ID is unknown
return;
}

await env.clipboard.writeText(participantId);
window.showInformationMessage('Participant ID has been copied to clipboard.');
}
3 changes: 2 additions & 1 deletion vscode-bugbuddy/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from 'vscode';
import { disconnectServer, generateParticipantId, setDataDirPath, showServerMenu, startServer } from './client';
import { copyParticipantId, disconnectServer, generateParticipantId, setDataDirPath, showServerMenu, startServer } from './client';
import { disposeTerminal, runFromUri } from './runner';
import { getWorkspaceConfig, initializeStatusBar, setExtensionId } from './utils';

Expand All @@ -9,6 +9,7 @@ export function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand('bugbuddy.run', runFromUri),
vscode.commands.registerCommand('bugbuddy.showServerMenu', showServerMenu),
vscode.commands.registerCommand('bugbuddy.generateParticipantId', generateParticipantId),
vscode.commands.registerCommand('bugbuddy.copyParticipantId', copyParticipantId),
);

// register a URI handler for the `openError` command
Expand Down

0 comments on commit 786194f

Please sign in to comment.