fix: summary newline logic
This commit is contained in:
parent
031a223995
commit
c1c6183db1
@ -5,19 +5,18 @@ import { Text } from "../text";
|
|||||||
export function StreamSummary({ text }: { text: string }) {
|
export function StreamSummary({ text }: { text: string }) {
|
||||||
const [expand, setExpand] = useState(false);
|
const [expand, setExpand] = useState(false);
|
||||||
|
|
||||||
const cutOff = Math.min(
|
const line3 = [...text].reduce(
|
||||||
100,
|
(acc, v, i) => {
|
||||||
[...text].reduce(
|
if (v === "\n" && acc[0] < 3) {
|
||||||
(acc, v, i) => {
|
acc[0] += 1;
|
||||||
if (v === "\n" && acc[0] < 3) {
|
acc[1] = i;
|
||||||
acc[0] += 1;
|
}
|
||||||
acc[1] = i;
|
return acc;
|
||||||
}
|
},
|
||||||
return acc;
|
[0, 0],
|
||||||
},
|
)[1];
|
||||||
[0, 0],
|
|
||||||
)[1],
|
const cutOff = Math.min(100, line3 > 0 ? line3 : text.length);
|
||||||
);
|
|
||||||
const shouldExpand = text.length > cutOff;
|
const shouldExpand = text.length > cutOff;
|
||||||
return (
|
return (
|
||||||
<div className="whitespace-pre text-pretty">
|
<div className="whitespace-pre text-pretty">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user