MCPcopy Create free account
hub / github.com/cursor/cookbook / wrapText

Function wrapText

sdk/coding-agent-cli/src/tui/App.tsx:763–788  ·  view source on GitHub ↗
(value: string, width: number)

Source from the content-addressed store, hash-verified

761}
762
763function wrapText(value: string, width: number) {
764 const lines: string[] = []
765
766 for (const rawLine of value.split("\n")) {
767 let line = rawLine
768
769 if (!line) {
770 lines.push("")
771 continue
772 }
773
774 while (line.length > width) {
775 let breakAt = line.lastIndexOf(" ", width)
776 if (breakAt < width * 0.5) {
777 breakAt = width
778 }
779
780 lines.push(line.slice(0, breakAt).trimEnd())
781 line = line.slice(breakAt).trimStart()
782 }
783
784 lines.push(line)
785 }
786
787 return lines
788}
789
790function parseInlineMarkdown(value: string): TranscriptPart[] {
791 const parts: TranscriptPart[] = []

Callers 2

buildTranscriptLinesFunction · 0.85
renderMarkdownLinesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected