MCPcopy Create free account
hub / github.com/modem-dev/hunk / spansToPlainText

Function spansToPlainText

src/ui/diff/renderRows.tsx:426–440  ·  view source on GitHub ↗

Convert a list of spans to fixed-width plain text while preserving logical clipping.

(spans: RenderSpan[], width: number, horizontalOffset = 0)

Source from the content-addressed store, hash-verified

424
425/** Convert a list of spans to fixed-width plain text while preserving logical clipping. */
426function spansToPlainText(spans: RenderSpan[], width: number, horizontalOffset = 0) {
427 if (width <= 0) {
428 return "";
429 }
430
431 const visible = sliceTextByWidth(
432 sanitizeTerminalSpans(spans)
433 .map((span) => span.text)
434 .join(""),
435 Math.max(0, horizontalOffset),
436 width,
437 );
438
439 return padTextByWidth(visible.text, Math.max(0, width));
440}
441
442/** Flatten styled spans to their visible text content. */
443function spansText(spans: RenderSpan[]) {

Callers 2

buildPlainSplitCellLinesFunction · 0.85
buildPlainStackCellLinesFunction · 0.85

Calls 2

sliceTextByWidthFunction · 0.90
sanitizeTerminalSpansFunction · 0.90

Tested by

no test coverage detected