fix(core/formatter): remove trailing whitespace before truncating (#476)

This commit is contained in:
ben-nasi
2025-11-07 18:37:22 +01:00
committed by GitHub
parent 88f14f52fe
commit dd7b723aac
+3 -1
View File
@@ -700,7 +700,9 @@ export abstract class BaseFormatter {
const n = parseInt(inside, 10);
if (!isNaN(n) && n >= 0) {
if (variable.length > n) {
return variable.slice(0, n) + '…';
// Truncate to N characters and remove trailing whitespace
const truncated = variable.slice(0, n).replace(/\s+$/, '');
return truncated + '…';
}
return variable;
}