From 529ea273a39bfe32cbed44e90c5d599a1839e2f3 Mon Sep 17 00:00:00 2001 From: Nate Date: Wed, 23 Apr 2025 18:24:48 -0700 Subject: [PATCH] hide terminal button in jetbrains --- .../RunInTerminalButton.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton.tsx b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton.tsx index a50c953f4..6154b3452 100644 --- a/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton.tsx +++ b/gui/src/components/StyledMarkdownPreview/StepContainerPreToolbar/RunInTerminalButton.tsx @@ -2,6 +2,7 @@ import { CommandLineIcon } from "@heroicons/react/24/outline"; import { useContext } from "react"; import { lightGray, vscForeground } from "../.."; import { IdeMessengerContext } from "../../../context/IdeMessenger"; +import { isJetBrains } from "../../../util"; interface RunInTerminalButtonProps { command: string; @@ -10,16 +11,21 @@ interface RunInTerminalButtonProps { export function RunInTerminalButton({ command }: RunInTerminalButtonProps) { const ideMessenger = useContext(IdeMessengerContext); + if (isJetBrains()) { + // JetBrains plugin doesn't currently have a way to run the command in the terminal for the user + return null; + } + // Extract just the command line (the line after $ or the first line) function extractCommand(cmd: string): string { // If the command contains a $ prompt, extract the line after it - if (cmd.includes('$')) { + if (cmd.includes("$")) { const match = cmd.match(/\$\s*([^\n]+)/); - return match ? match[1].trim() : ''; + return match ? match[1].trim() : ""; } - + // Otherwise, just take the first line - return cmd.split('\n')[0].trim(); + return cmd.split("\n")[0].trim(); } function runInTerminal() {