Changesets · Branches · Tags · Compare
| Changeset | cb3a66212c03c314847ddf6611d798545ed557cf4b045aec59a30ecf619fecc0 |
|---|---|
| Author | uinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-09-16 20:21 +05:30 |
| Committer | uinstinct <61635505+uinstinct@users.noreply.github.com> · 2025-09-16 20:21 +05:30 |
| Parents | c093109a6490 |
2 files changed
modified gui/src/pages/gui/ToolCallDiv/FindAndReplace.tsx +8 −3
| @@ -13,7 +13,10 @@ | ||
| 13 | 13 | selectApplyStateByToolCallId, |
| 14 | 14 | selectToolCallById, |
| 15 | 15 | } from "../../../redux/selectors/selectToolCalls"; |
| 16 | -import { performFindAndReplace } from "../../../util/clientTools/findAndReplaceUtils"; | |
| 16 | +import { | |
| 17 | + performFindAndReplace, | |
| 18 | + removeEmptyLines, | |
| 19 | +} from "../../../util/clientTools/findAndReplaceUtils"; | |
| 17 | 20 | import { cn } from "../../../util/cn"; |
| 18 | 21 | import { getStatusIcon } from "./utils"; |
| 19 | 22 | |
| @@ -313,14 +316,16 @@ | ||
| 313 | 316 | const showMiddleEllipses = |
| 314 | 317 | !isFirst && !isLast && lines.length > MAX_SAME_LINES * 2 + 1; |
| 315 | 318 | |
| 316 | - const startLines = showStartEllipsis | |
| 319 | + let startLines = showStartEllipsis | |
| 317 | 320 | ? lines.slice(-MAX_SAME_LINES) |
| 318 | 321 | : showMiddleEllipses || showEndEllipsis |
| 319 | 322 | ? lines.slice(0, MAX_SAME_LINES) |
| 320 | 323 | : lines; |
| 321 | - const endLines = showMiddleEllipses | |
| 324 | + startLines = removeEmptyLines.fromStart(startLines); | |
| 325 | + let endLines = showMiddleEllipses | |
| 322 | 326 | ? lines.slice(-MAX_SAME_LINES) |
| 323 | 327 | : []; |
| 328 | + endLines = removeEmptyLines.fromEnd(endLines); | |
| 324 | 329 | |
| 325 | 330 | return ( |
| 326 | 331 | <div key={index}> |
modified gui/src/util/clientTools/findAndReplaceUtils.ts +22 −0
| @@ -95,3 +95,25 @@ | ||
| 95 | 95 | |
| 96 | 96 | return isCreating; |
| 97 | 97 | } |
| 98 | + | |
| 99 | +/**remove all empty lines from the start/end in an array of lines */ | |
| 100 | +export const removeEmptyLines = { | |
| 101 | + _remove: (lines: string[]) => { | |
| 102 | + const newLines = []; | |
| 103 | + let index = 0, | |
| 104 | + shouldContinueRemoving = true; | |
| 105 | + while (index < lines.length) { | |
| 106 | + if (shouldContinueRemoving && lines[index].trim() === "") { | |
| 107 | + index++; | |
| 108 | + continue; | |
| 109 | + } | |
| 110 | + shouldContinueRemoving = false; | |
| 111 | + newLines.push(lines[index]); | |
| 112 | + index++; | |
| 113 | + } | |
| 114 | + return newLines; | |
| 115 | + }, | |
| 116 | + fromStart: (lines: string[]) => removeEmptyLines._remove(lines), | |
| 117 | + fromEnd: (lines: string[]) => | |
| 118 | + removeEmptyLines._remove(lines.toReversed()).toReversed(), | |
| 119 | +}; |