MCPcopy Create free account
hub / github.com/codeaashu/claude-code / truncateLine

Function truncateLine

src/commands/copy/copy.tsx:95–110  ·  view source on GitHub ↗
(text: string, maxLen: number)

Source from the content-addressed store, hash-verified

93 }
94}
95function truncateLine(text: string, maxLen: number): string {
96 const firstLine = text.split('\n')[0] ?? '';
97 if (stringWidth(firstLine) <= maxLen) {
98 return firstLine;
99 }
100 let result = '';
101 let width = 0;
102 const targetWidth = maxLen - 1;
103 for (const char of firstLine) {
104 const charWidth = stringWidth(char);
105 if (width + charWidth > targetWidth) break;
106 result += char;
107 width += charWidth;
108 }
109 return result + '\u2026';
110}
111type PickerProps = {
112 fullText: string;
113 codeBlocks: CodeBlock[];

Callers 1

_tempFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected