Changesets · Branches · Tags · Compare
| Changeset | dd35e28818ae3c19a1b61c9a150f3315580ea427ce74af2a98a3ffd76e051950 |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-09-09 12:16 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-09-09 12:16 -07:00 |
| Parents | bc3425f09bf8, 6ab5f01bc469 |
1 file changed
modified gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx +14 −2
| @@ -4,7 +4,7 @@ | ||
| 4 | 4 | import { renderContextItems } from "core/util/messageContent"; |
| 5 | 5 | import { getLastNPathParts, getUriPathBasename } from "core/util/uri"; |
| 6 | 6 | import { diffLines } from "diff"; |
| 7 | -import { useContext, useMemo, useState } from "react"; | |
| 7 | +import { useContext, useEffect, useMemo, useRef, useState } from "react"; | |
| 8 | 8 | import { ApplyActions } from "../../../components/StyledMarkdownPreview/StepContainerPreToolbar/ApplyActions"; |
| 9 | 9 | import { FileInfo } from "../../../components/StyledMarkdownPreview/StepContainerPreToolbar/FileInfo"; |
| 10 | 10 | import { IdeMessengerContext } from "../../../context/IdeMessenger"; |
| @@ -77,6 +77,8 @@ | ||
| 77 | 77 | historyIndex, |
| 78 | 78 | }: FindAndReplaceDisplayProps) { |
| 79 | 79 | const [isExpanded, setIsExpanded] = useState<boolean | undefined>(undefined); |
| 80 | + const [diffWidth, setDiffWidth] = useState<number | undefined>(undefined); | |
| 81 | + const diffDivRef = useRef<HTMLDivElement>(null); | |
| 80 | 82 | const ideMessenger = useContext(IdeMessengerContext); |
| 81 | 83 | const applyState: ApplyState | undefined = useAppSelector((state) => |
| 82 | 84 | selectApplyStateByToolCallId(state, toolCallId), |
| @@ -236,12 +238,22 @@ | ||
| 236 | 238 | ); |
| 237 | 239 | } |
| 238 | 240 | |
| 241 | + useEffect(() => { | |
| 242 | + if (!diffDivRef.current) return; | |
| 243 | + const newWidth = | |
| 244 | + diffDivRef.current?.scrollWidth ?? | |
| 245 | + diffDivRef.current?.getBoundingClientRect().width; | |
| 246 | + setDiffWidth(newWidth ? Math.ceil(newWidth) : undefined); | |
| 247 | + }, [isExpanded]); | |
| 248 | + | |
| 239 | 249 | return renderContainer( |
| 240 | 250 | <div |
| 241 | 251 | className={`${config?.ui?.showChatScrollbar ? "thin-scrollbar" : "no-scrollbar"} max-h-72 overflow-auto`} |
| 252 | + ref={diffDivRef} | |
| 242 | 253 | > |
| 243 | 254 | <pre |
| 244 | - className={`bg-editor m-0 w-full text-xs leading-tight ${config?.ui?.codeWrap ? "whitespace-pre-wrap" : "whitespace-pre"}`} | |
| 255 | + className={`bg-editor m-0 text-xs leading-tight ${config?.ui?.codeWrap ? "whitespace-pre-wrap" : "whitespace-pre"}`} | |
| 256 | + style={{ width: diffWidth ? `${diffWidth}px` : "100%" }} | |
| 245 | 257 | > |
| 246 | 258 | {diffResult.diff?.map((part, index) => { |
| 247 | 259 | if (part.removed) { |