Elffuss BraidHub

kikocis/continue public

Merge pull request #7653 from uinstinct/diff-color-reach

fix: diff colors should reach till end
Changesetdd35e28818ae3c19a1b61c9a150f3315580ea427ce74af2a98a3ffd76e051950
AuthorDallin Romney <dallinromney@gmail.com> · 2025-09-09 12:16 -07:00
CommitterGitHub <noreply@github.com> · 2025-09-09 12:16 -07:00
Parentsbc3425f09bf8, 6ab5f01bc469

Browse the files at this changeset

1 file changed

modified gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx +14 −2
@@ -4,7 +4,7 @@
44 import { renderContextItems } from "core/util/messageContent";
55 import { getLastNPathParts, getUriPathBasename } from "core/util/uri";
66 import { diffLines } from "diff";
7-import { useContext, useMemo, useState } from "react";
7+import { useContext, useEffect, useMemo, useRef, useState } from "react";
88 import { ApplyActions } from "../../../components/StyledMarkdownPreview/StepContainerPreToolbar/ApplyActions";
99 import { FileInfo } from "../../../components/StyledMarkdownPreview/StepContainerPreToolbar/FileInfo";
1010 import { IdeMessengerContext } from "../../../context/IdeMessenger";
@@ -77,6 +77,8 @@
7777 historyIndex,
7878 }: FindAndReplaceDisplayProps) {
7979 const [isExpanded, setIsExpanded] = useState<boolean | undefined>(undefined);
80+ const [diffWidth, setDiffWidth] = useState<number | undefined>(undefined);
81+ const diffDivRef = useRef<HTMLDivElement>(null);
8082 const ideMessenger = useContext(IdeMessengerContext);
8183 const applyState: ApplyState | undefined = useAppSelector((state) =>
8284 selectApplyStateByToolCallId(state, toolCallId),
@@ -236,12 +238,22 @@
236238 );
237239 }
238240
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+
239249 return renderContainer(
240250 <div
241251 className={`${config?.ui?.showChatScrollbar ? "thin-scrollbar" : "no-scrollbar"} max-h-72 overflow-auto`}
252+ ref={diffDivRef}
242253 >
243254 <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%" }}
245257 >
246258 {diffResult.diff?.map((part, index) => {
247259 if (part.removed) {