@@ -108,7 +108,7 @@ const tests = [
108108 env : { NODE_REPL_HISTORY : defaultHistoryPath } ,
109109 skip : ! process . features . inspector ,
110110 test : [
111- `const ${ 'veryLongName' . repeat ( 30 ) } = 'I should not be previewed'` ,
111+ `const ${ 'veryLongName' . repeat ( 30 ) } = 'I should be previewed'` ,
112112 ENTER ,
113113 'const e = new RangeError("visible\\ninvisible")' ,
114114 ENTER ,
@@ -127,27 +127,70 @@ const tests = [
127127 {
128128 env : { NODE_REPL_HISTORY : defaultHistoryPath } ,
129129 columns : 250 ,
130+ showEscapeCodes : true ,
130131 skip : ! process . features . inspector ,
131132 test : [
132133 UP ,
133134 UP ,
134135 UP ,
136+ WORD_LEFT ,
135137 UP ,
136138 BACKSPACE
137139 ] ,
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
138147 expected : [
139- prompt ,
148+ // 0. Start
149+ '\x1B[1G' , '\x1B[0J' ,
150+ prompt , '\x1B[3G' ,
151+ // 1. UP
140152 // This exceeds the maximum columns (250):
141153 // Whitespace + prompt + ' // '.length + 'function'.length
142154 // 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'
151194 ] ,
152195 clean : true
153196 } ,
@@ -169,11 +212,11 @@ const tests = [
169212 WORD_RIGHT ,
170213 ENTER
171214 ] ,
172- // C = Cursor forward
173- // D = Cursor back
215+ // C = Cursor n forward
216+ // D = Cursor n back
174217 // 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
177220 expected : [
178221 // 0.
179222 // 'f'
0 commit comments