hide terminal button in jetbrains

This commit is contained in:
Nate 2025-04-23 18:24:48 -07:00
parent 10a264e2c6
commit 529ea273a3

View file

@ -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() {