From b10c87422a7c456c3a2b8745146ffae88c1dd1d4 Mon Sep 17 00:00:00 2001 From: daniel-lxs Date: Tue, 23 Sep 2025 14:57:26 -0500 Subject: [PATCH] feat: add clipboard copy functionality to openImage for file paths --- src/integrations/misc/image-handler.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/integrations/misc/image-handler.ts b/src/integrations/misc/image-handler.ts index e0af2b19e6..d16a13ee32 100644 --- a/src/integrations/misc/image-handler.ts +++ b/src/integrations/misc/image-handler.ts @@ -16,10 +16,14 @@ export async function openImage(dataUriOrPath: string, options?: { values?: { ac if (fsPath.startsWith("/file/")) { fsPath = fsPath.slice("/file/".length) } - fsPath = path.normalize(fsPath) if (fsPath) { const fileUri = vscode.Uri.file(fsPath) + if (options?.values?.action === "copy") { + await vscode.env.clipboard.writeText(fsPath) + vscode.window.showInformationMessage(t("common:info.path_copied_to_clipboard")) + return + } await vscode.commands.executeCommand("vscode.open", fileUri) return } @@ -32,6 +36,13 @@ export async function openImage(dataUriOrPath: string, options?: { values?: { ac if (dataUriOrPath.startsWith("file://")) { try { const fileUri = vscode.Uri.parse(dataUriOrPath) + const filePath = fileUri.fsPath + + if (options?.values?.action === "copy") { + await vscode.env.clipboard.writeText(filePath) + vscode.window.showInformationMessage(t("common:info.path_copied_to_clipboard")) + return + } await vscode.commands.executeCommand("vscode.open", fileUri) } catch (error) {