Merge pull request #5351 from continuedev/nate/rg
Fix ripgrep in jetbrains
This commit is contained in:
commit
6ab6a376cc
4 changed files with 81 additions and 52 deletions
|
|
@ -42,7 +42,7 @@ class IntelliJIDE(
|
|||
private val project: Project,
|
||||
private val continuePluginService: ContinuePluginService,
|
||||
|
||||
) : IDE {
|
||||
) : IDE {
|
||||
|
||||
private val gitService = GitService(project, continuePluginService)
|
||||
|
||||
|
|
@ -57,6 +57,19 @@ class IntelliJIDE(
|
|||
val os = getOS()
|
||||
ripgrep =
|
||||
Paths.get(pluginPath.toString(), "ripgrep", "bin", "rg" + if (os == OS.WINDOWS) ".exe" else "").toString()
|
||||
|
||||
// Make ripgrep executable if on Unix-like systems
|
||||
try {
|
||||
if (os == OS.LINUX || os == OS.MAC) {
|
||||
val file = File(ripgrep)
|
||||
if (!file.canExecute()) {
|
||||
file.setExecutable(true)
|
||||
}
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -311,7 +324,7 @@ class IntelliJIDE(
|
|||
val ideInfo = this.getIdeInfo()
|
||||
if (ideInfo.remoteName == "local") {
|
||||
val command = GeneralCommandLine(
|
||||
ripgrep,
|
||||
ripgrep,
|
||||
"--files",
|
||||
"--iglob",
|
||||
pattern,
|
||||
|
|
@ -320,37 +333,37 @@ class IntelliJIDE(
|
|||
"--ignore-file",
|
||||
".gitignore",
|
||||
)
|
||||
|
||||
|
||||
command.setWorkDirectory(project.basePath)
|
||||
val results = ExecUtil.execAndGetOutput(command).stdout
|
||||
return results.split("\n")
|
||||
} else {
|
||||
throw NotImplementedError("Ripgrep not supported, this workspace is remote")
|
||||
throw NotImplementedError("Ripgrep not supported, this workspace is remote")
|
||||
|
||||
// Leaving in here for ideas
|
||||
// val projectBasePath = project.basePath ?: return emptyList()
|
||||
// val scope = GlobalSearchScope.projectScope(project)
|
||||
//
|
||||
// // Get all ignore patterns from .continueignore files
|
||||
// val ignorePatterns = mutableSetOf<String>()
|
||||
// VirtualFileManager.getInstance().findFileByUrl("file://$projectBasePath")?.let { root ->
|
||||
// VfsUtil.collectChildrenRecursively(root).forEach { file ->
|
||||
// if (file.name == ".continueignore") {
|
||||
// file.inputStream.bufferedReader().useLines { lines ->
|
||||
// ignorePatterns.addAll(lines.filter { it.isNotBlank() && !it.startsWith("#") })
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return FilenameIndex.getAllFilesByExt(project, "*", scope)
|
||||
// .filter { file ->
|
||||
// val relativePath = file.path.removePrefix("$projectBasePath/")
|
||||
// // Check if file matches pattern and isn't ignored
|
||||
// PatternUtil.(relativePath, pattern) &&
|
||||
// !ignorePatterns.any { PatternUtil.matchesGlob(relativePath, it) }
|
||||
// }
|
||||
// .map { it.path.removePrefix("$projectBasePath/") }
|
||||
// Leaving in here for ideas
|
||||
// val projectBasePath = project.basePath ?: return emptyList()
|
||||
// val scope = GlobalSearchScope.projectScope(project)
|
||||
//
|
||||
// // Get all ignore patterns from .continueignore files
|
||||
// val ignorePatterns = mutableSetOf<String>()
|
||||
// VirtualFileManager.getInstance().findFileByUrl("file://$projectBasePath")?.let { root ->
|
||||
// VfsUtil.collectChildrenRecursively(root).forEach { file ->
|
||||
// if (file.name == ".continueignore") {
|
||||
// file.inputStream.bufferedReader().useLines { lines ->
|
||||
// ignorePatterns.addAll(lines.filter { it.isNotBlank() && !it.startsWith("#") })
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return FilenameIndex.getAllFilesByExt(project, "*", scope)
|
||||
// .filter { file ->
|
||||
// val relativePath = file.path.removePrefix("$projectBasePath/")
|
||||
// // Check if file matches pattern and isn't ignored
|
||||
// PatternUtil.(relativePath, pattern) &&
|
||||
// !ignorePatterns.any { PatternUtil.matchesGlob(relativePath, it) }
|
||||
// }
|
||||
// .map { it.path.removePrefix("$projectBasePath/") }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -358,20 +371,20 @@ class IntelliJIDE(
|
|||
val ideInfo = this.getIdeInfo()
|
||||
if (ideInfo.remoteName == "local") {
|
||||
val command = GeneralCommandLine(
|
||||
ripgrep,
|
||||
"-i",
|
||||
ripgrep,
|
||||
"-i",
|
||||
"--ignore-file",
|
||||
".continueignore",
|
||||
"--ignore-file",
|
||||
".gitignore",
|
||||
"-C",
|
||||
"2",
|
||||
"--heading",
|
||||
"-e",
|
||||
query,
|
||||
".gitignore",
|
||||
"-C",
|
||||
"2",
|
||||
"--heading",
|
||||
"-e",
|
||||
query,
|
||||
"."
|
||||
)
|
||||
|
||||
|
||||
command.setWorkDirectory(project.basePath)
|
||||
return ExecUtil.execAndGetOutput(command).stdout
|
||||
} else {
|
||||
|
|
@ -415,7 +428,7 @@ class IntelliJIDE(
|
|||
// return searchResults.toString()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
override suspend fun subprocess(command: String, cwd: String?): List<Any> {
|
||||
val commandList = command.split(" ")
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,12 @@ import { selectCurrentToolCall } from "../../../redux/selectors/selectCurrentToo
|
|||
import { callCurrentTool } from "../../../redux/thunks/callCurrentTool";
|
||||
import { cancelCurrentToolCall } from "../../../redux/thunks/cancelCurrentToolCall";
|
||||
import { cancelStream } from "../../../redux/thunks/cancelStream";
|
||||
import { getFontSize, getMetaKeyLabel } from "../../../util";
|
||||
import {
|
||||
getAltKeyLabel,
|
||||
getFontSize,
|
||||
getMetaKeyLabel,
|
||||
isJetBrains,
|
||||
} from "../../../util";
|
||||
import { EnterButton } from "../InputToolbar/EnterButton";
|
||||
import { BlockSettingsTopToolbar } from "./BlockSettingsTopToolbar";
|
||||
|
||||
|
|
@ -40,18 +45,20 @@ export function LumpToolbar() {
|
|||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const ttsActive = useAppSelector((state) => state.ui.ttsActive);
|
||||
const isStreaming = useAppSelector((state) => state.session.isStreaming);
|
||||
const jetbrains = isJetBrains();
|
||||
|
||||
const toolCallState = useSelector(selectCurrentToolCall);
|
||||
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (toolCallState?.status === "generated") {
|
||||
const metaKey = event.metaKey || event.ctrlKey;
|
||||
const altKey = event.altKey;
|
||||
|
||||
if (metaKey && event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
dispatch(callCurrentTool());
|
||||
} else if (metaKey && event.key === "Backspace") {
|
||||
} else if ((jetbrains ? altKey : metaKey) && event.key === "Backspace") {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
dispatch(cancelCurrentToolCall());
|
||||
|
|
@ -92,7 +99,8 @@ export function LumpToolbar() {
|
|||
dispatch(cancelStream());
|
||||
}}
|
||||
>
|
||||
{getMetaKeyLabel()} ⌫ Cancel
|
||||
{/* JetBrains overrides cmd+backspace, so we have to use another shortcut */}
|
||||
{jetbrains ? getAltKeyLabel() : getMetaKeyLabel()} ⌫ Cancel
|
||||
</StopButton>
|
||||
</Container>
|
||||
);
|
||||
|
|
@ -109,7 +117,8 @@ export function LumpToolbar() {
|
|||
onClick={() => dispatch(cancelCurrentToolCall())}
|
||||
data-testid="reject-tool-call-button"
|
||||
>
|
||||
{getMetaKeyLabel()} ⌫ Cancel
|
||||
{/* JetBrains overrides cmd+backspace, so we have to use another shortcut */}
|
||||
{jetbrains ? getAltKeyLabel() : getMetaKeyLabel()} ⌫ Cancel
|
||||
</StopButton>
|
||||
<EnterButton
|
||||
isPrimary={true}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ import { cancelStream } from "../../redux/thunks/cancelStream";
|
|||
import { exitEditMode } from "../../redux/thunks/exitEditMode";
|
||||
import { loadLastSession } from "../../redux/thunks/session";
|
||||
import { streamResponseThunk } from "../../redux/thunks/streamResponse";
|
||||
import { isMetaEquivalentKeyPressed } from "../../util";
|
||||
import { isJetBrains, isMetaEquivalentKeyPressed } from "../../util";
|
||||
import {
|
||||
FREE_TRIAL_LIMIT_REQUESTS,
|
||||
incrementFreeTrialCount,
|
||||
|
|
@ -130,14 +130,15 @@ export function Chat() {
|
|||
const hasDismissedExploreDialog = useAppSelector(
|
||||
(state) => state.ui.hasDismissedExploreDialog,
|
||||
);
|
||||
const jetbrains = isJetBrains();
|
||||
|
||||
useEffect(() => {
|
||||
// Cmd + Backspace to delete current step
|
||||
const listener = (e: any) => {
|
||||
if (
|
||||
e.key === "Backspace" &&
|
||||
isMetaEquivalentKeyPressed(e) &&
|
||||
!e.shiftKey
|
||||
e.key === "Backspace" && jetbrains
|
||||
? e.altKey
|
||||
: isMetaEquivalentKeyPressed(e) && !e.shiftKey
|
||||
) {
|
||||
dispatch(cancelStream());
|
||||
}
|
||||
|
|
@ -339,8 +340,8 @@ export function Chat() {
|
|||
inputId={item.message.id}
|
||||
/>
|
||||
</>
|
||||
) : item.message.role === "tool" ? null : // /> // toolCallId={item.message.toolCallId} // contextItems={item.contextItems} // <ToolOutput
|
||||
item.message.role === "assistant" &&
|
||||
) : item.message.role === "tool" ? null : item.message.role === // /> // toolCallId={item.message.toolCallId} // contextItems={item.contextItems} // <ToolOutput
|
||||
"assistant" &&
|
||||
item.message.toolCalls &&
|
||||
item.toolCallState ? (
|
||||
<div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue