@@ -108,7 +108,7 @@ const tests = [
108
108
env : { NODE_REPL_HISTORY : defaultHistoryPath } ,
109
109
skip : ! process . features . inspector ,
110
110
test : [
111
- `const ${ 'veryLongName' . repeat ( 30 ) } = 'I should not be previewed'` ,
111
+ `const ${ 'veryLongName' . repeat ( 30 ) } = 'I should be previewed'` ,
112
112
ENTER ,
113
113
'const e = new RangeError("visible\\ninvisible")' ,
114
114
ENTER ,
@@ -127,27 +127,70 @@ const tests = [
127
127
{
128
128
env : { NODE_REPL_HISTORY : defaultHistoryPath } ,
129
129
columns : 250 ,
130
+ showEscapeCodes : true ,
130
131
skip : ! process . features . inspector ,
131
132
test : [
132
133
UP ,
133
134
UP ,
134
135
UP ,
136
+ WORD_LEFT ,
135
137
UP ,
136
138
BACKSPACE
137
139
] ,
140
+ // A = Cursor n up
141
+ // B = Cursor n down
142
+ // C = Cursor n forward
143
+ // D = Cursor n back
144
+ // G = Cursor to column n
145
+ // J = Erase in screen; 0 = right; 1 = left; 2 = total
146
+ // K = Erase in line; 0 = right; 1 = left; 2 = total
138
147
expected : [
139
- prompt ,
148
+ // 0. Start
149
+ '\x1B[1G' , '\x1B[0J' ,
150
+ prompt , '\x1B[3G' ,
151
+ // 1. UP
140
152
// This exceeds the maximum columns (250):
141
153
// Whitespace + prompt + ' // '.length + 'function'.length
142
154
// 236 + 2 + 4 + 8
143
- `${ prompt } ${ ' ' . repeat ( 236 ) } fun` ,
144
- `${ prompt } ${ ' ' . repeat ( 235 ) } fun` ,
145
- ' // ction' ,
146
- ' // ction' ,
147
- `${ prompt } ${ 'veryLongName' . repeat ( 30 ) } ` ,
148
- `${ prompt } e` ,
149
- '\n// RangeError: visible' ,
150
- prompt
155
+ '\x1B[1G' , '\x1B[0J' ,
156
+ `${ prompt } ${ ' ' . repeat ( 236 ) } fun` , '\x1B[243G' ,
157
+ // 2. UP
158
+ '\x1B[1G' , '\x1B[0J' ,
159
+ `${ prompt } ${ ' ' . repeat ( 235 ) } fun` , '\x1B[242G' ,
160
+ // TODO(BridgeAR): Investigate why the preview is generated twice.
161
+ ' // ction' , '\x1B[242G' ,
162
+ ' // ction' , '\x1B[242G' ,
163
+ // Preview cleanup
164
+ '\x1B[0K' ,
165
+ // 3. UP
166
+ '\x1B[1G' , '\x1B[0J' ,
167
+ // 'veryLongName'.repeat(30).length === 360
168
+ // prompt.length === 2
169
+ // 360 % 250 + 2 === 112 (+1)
170
+ `${ prompt } ${ 'veryLongName' . repeat ( 30 ) } ` , '\x1B[113G' ,
171
+ // "// 'I should be previewed'".length + 86 === 112 (+1)
172
+ "\n// 'I should be previewed'" , '\x1B[86C\x1B[1A' ,
173
+ // Preview cleanup
174
+ '\x1B[1B' , '\x1B[2K' , '\x1B[1A' ,
175
+ // 4. WORD LEFT
176
+ // Almost identical as above. Just one extra line.
177
+ // Math.floor(360 / 250) === 1
178
+ '\x1B[1A' ,
179
+ '\x1B[1G' , '\x1B[0J' ,
180
+ `${ prompt } ${ 'veryLongName' . repeat ( 30 ) } ` , '\x1B[3G' , '\x1B[1A' ,
181
+ '\x1B[1B' , "\n// 'I should be previewed'" , '\x1B[24D\x1B[2A' ,
182
+ // Preview cleanup
183
+ '\x1B[2B' , '\x1B[2K' , '\x1B[2A' ,
184
+ // 5. UP
185
+ '\x1B[1G' , '\x1B[0J' ,
186
+ `${ prompt } e` , '\x1B[4G' ,
187
+ // '// RangeError: visible'.length - 19 === 3 (+1)
188
+ '\n// RangeError: visible' , '\x1B[19D\x1B[1A' ,
189
+ // Preview cleanup
190
+ '\x1B[1B' , '\x1B[2K' , '\x1B[1A' ,
191
+ // 6. Backspace
192
+ '\x1B[1G' , '\x1B[0J' ,
193
+ prompt , '\x1B[3G'
151
194
] ,
152
195
clean : true
153
196
} ,
@@ -169,11 +212,11 @@ const tests = [
169
212
WORD_RIGHT ,
170
213
ENTER
171
214
] ,
172
- // C = Cursor forward
173
- // D = Cursor back
215
+ // C = Cursor n forward
216
+ // D = Cursor n back
174
217
// G = Cursor to column n
175
- // J = Erase in screen
176
- // K = Erase in line
218
+ // J = Erase in screen; 0 = right; 1 = left; 2 = total
219
+ // K = Erase in line; 0 = right; 1 = left; 2 = total
177
220
expected : [
178
221
// 0.
179
222
// 'f'
0 commit comments