MCPcopy Create free account
hub / github.com/banga/git-split-diffs / iterFitTextToWidth

Function iterFitTextToWidth

src/iterFitTextToWidth.ts:10–34  ·  view source on GitHub ↗
(
    context: Context,
    formattedString: FormattedString,
    width: number,
    backgroundColor?: ThemeColor
)

Source from the content-addressed store, hash-verified

8 * the config.
9 */
10export function* iterFitTextToWidth(
11 context: Context,
12 formattedString: FormattedString,
13 width: number,
14 backgroundColor?: ThemeColor
15): Iterable<FormattedString> {
16 if (context.WRAP_LINES) {
17 for (const wrappedLine of wrapSpannedStringByWord(
18 formattedString,
19 width
20 )) {
21 wrappedLine.fillWidth(width);
22 if (backgroundColor) {
23 wrappedLine.addSpan(0, width, backgroundColor);
24 }
25 yield wrappedLine;
26 }
27 } else {
28 const truncatedLine = formattedString.slice(0, width).fillWidth(width);
29 if (backgroundColor) {
30 truncatedLine.addSpan(0, width, backgroundColor);
31 }
32 yield truncatedLine;
33 }
34}

Callers 5

iterFormatHunkFunction · 0.90
iterFormatCommitBodyLineFunction · 0.90
formatAndFitHunkLineFunction · 0.90
iterFormatFileNameFunction · 0.90

Calls 4

wrapSpannedStringByWordFunction · 0.90
fillWidthMethod · 0.80
addSpanMethod · 0.80
sliceMethod · 0.80

Tested by

no test coverage detected