hedgequantx 2.9.246 → 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.246",
3
+ "version": "2.9.247",
4
4
  "description": "HedgeQuantX - Prop Futures Trading CLI",
5
5
  "main": "src/app.js",
6
6
  "bin": {
@@ -77,47 +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 characters (visible)
80
+ * Ensures output is EXACTLY width visible characters
81
81
  */
82
82
  const fitToWidth = (text, width) => {
83
83
  const plain = stripAnsi(text);
84
84
 
85
- if (plain.length > width) {
86
- // Need to truncate - find cut point accounting for ANSI codes
87
- let visibleCount = 0;
88
- let cutIndex = 0;
89
- let inAnsi = false;
90
-
91
- for (let i = 0; i < text.length; i++) {
92
- if (text[i] === '\x1B') {
93
- inAnsi = true;
94
- } else if (inAnsi && text[i] === 'm') {
95
- inAnsi = false;
96
- } else if (!inAnsi) {
97
- visibleCount++;
98
- if (visibleCount >= width - 2) {
99
- cutIndex = i + 1;
100
- break;
101
- }
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++;
102
101
  }
103
- cutIndex = i + 1;
104
- }
105
-
106
- // Truncate and add ".." (2 chars to stay within width)
107
- const truncated = text.substring(0, cutIndex);
108
- const truncatedPlain = stripAnsi(truncated);
109
- const remaining = width - truncatedPlain.length;
110
-
111
- if (remaining >= 2) {
112
- return truncated + '..' + ' '.repeat(remaining - 2);
113
- } else if (remaining > 0) {
114
- return truncated + ' '.repeat(remaining);
102
+ i++; // skip 'm'
103
+ } else {
104
+ visibleCount++;
105
+ i++;
115
106
  }
116
- return truncated;
107
+ cutIndex = i;
117
108
  }
118
109
 
119
- // Pad to exact width
120
- return text + ' '.repeat(width - plain.length);
110
+ return text.substring(0, cutIndex) + '..';
121
111
  };
122
112
 
123
113
  /**