fix(tui): trim leading space on word-wrapped continuation lines (#1346)

Co-authored-by: Letta Code <noreply@letta.com>
This commit is contained in:
Charles Packer
2026-03-10 21:08:24 -07:00
committed by GitHub
parent 13d86fbd7c
commit bfc9d4b25a
2 changed files with 32 additions and 0 deletions

31
vendor/ink/build/wrap-text.js vendored Normal file
View File

@@ -0,0 +1,31 @@
import wrapAnsi from 'wrap-ansi';
import cliTruncate from 'cli-truncate';
const cache = {};
const wrapText = (text, maxWidth, wrapType) => {
const cacheKey = text + String(maxWidth) + String(wrapType);
const cachedText = cache[cacheKey];
if (cachedText) {
return cachedText;
}
let wrappedText = text;
if (wrapType === 'wrap') {
wrappedText = wrapAnsi(text, maxWidth, {
trim: true,
hard: true,
});
}
if (wrapType.startsWith('truncate')) {
let position = 'end';
if (wrapType === 'truncate-middle') {
position = 'middle';
}
if (wrapType === 'truncate-start') {
position = 'start';
}
wrappedText = cliTruncate(text, maxWidth, { position });
}
cache[cacheKey] = wrappedText;
return wrappedText;
};
export default wrapText;
//# sourceMappingURL=wrap-text.js.map