Skip to content

Commit

Permalink
Fix crash when trying to copy numeric values to the clipboard (#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Mar 5, 2024
1 parent f3172a2 commit 7742b0e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/BrightScriptCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ export class BrightScriptCommands {

this.registerCommand('copyToClipboard', async (value: string) => {
try {
await vscode.env.clipboard.writeText(value);
if (util.isNullish(value)) {
throw new Error('Cannot copy ${value} to clipboard');
}
await vscode.env.clipboard.writeText(value?.toString());
await vscode.window.showInformationMessage(`Copied to clipboard: ${value}`);
} catch (error) {
await vscode.window.showErrorMessage(`Could not copy value to clipboard`);
Expand Down

0 comments on commit 7742b0e

Please sign in to comment.