hedgequantx 2.9.245 → 2.9.247

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hedgequantx",
3
- "version": "2.9.245",
3
+ "version": "2.9.247",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -77,18 +77,37 @@ const center = (text, width) => {
77
77
 
78
78
  /**
79
79
  * Fit text to exact width (truncate or pad)
80
+ * Ensures output is EXACTLY width visible characters
80
81
  */
81
82
  const fitToWidth = (text, width) => {
82
83
  const plain = stripAnsi(text);
83
- if (plain.length > width) {
84
- let count = 0, cut = 0;
85
- for (let i = 0; i < text.length && count < width - 3; i++) {
86
- if (text[i] === '\x1B') { while (i < text.length && text[i] !== 'm') i++; }
87
- else { count++; cut = i + 1; }
84
+
85
+ if (plain.length <= width) {
86
+ // Pad to exact width
87
+ return text + ' '.repeat(width - plain.length);
88
+ }
89
+
90
+ // Need to truncate to (width - 2) visible chars, then add ".."
91
+ const targetLen = width - 2;
92
+ let visibleCount = 0;
93
+ let cutIndex = 0;
94
+ let i = 0;
95
+
96
+ while (i < text.length && visibleCount < targetLen) {
97
+ if (text[i] === '\x1B') {
98
+ // Skip entire ANSI sequence
99
+ while (i < text.length && text[i] !== 'm') {
100
+ i++;
101
+ }
102
+ i++; // skip 'm'
103
+ } else {
104
+ visibleCount++;
105
+ i++;
88
106
  }
89
- return text.substring(0, cut) + '...';
107
+ cutIndex = i;
90
108
  }
91
- return text + ' '.repeat(width - plain.length);
109
+
110
+ return text.substring(0, cutIndex) + '..';
92
111
  };
93
112
 
94
113
  /**