@@ -491,6 +491,57 @@ suite('PromptInputModel', () => {
491
491
} ) ;
492
492
493
493
suite ( 'trailing whitespace' , ( ) => {
494
+ test ( 'cursor index calculation with whitespace' , async ( ) => {
495
+ await writePromise ( '$ ' ) ;
496
+ fireCommandStart ( ) ;
497
+ await assertPromptInput ( '|' ) ;
498
+
499
+ await writePromise ( 'echo ' ) ;
500
+ await assertPromptInput ( 'echo |' ) ;
501
+
502
+ await writePromise ( '\x1b[3D' ) ;
503
+ await assertPromptInput ( 'echo| ' ) ;
504
+
505
+ await writePromise ( '\x1b[C' ) ;
506
+ await assertPromptInput ( 'echo | ' ) ;
507
+
508
+ await writePromise ( '\x1b[C' ) ;
509
+ await assertPromptInput ( 'echo | ' ) ;
510
+
511
+ await writePromise ( '\x1b[C' ) ;
512
+ await assertPromptInput ( 'echo |' ) ;
513
+ } ) ;
514
+
515
+ test ( 'cursor index should not exceed command line length' , async ( ) => {
516
+ await writePromise ( '$ ' ) ;
517
+ fireCommandStart ( ) ;
518
+ await assertPromptInput ( '|' ) ;
519
+
520
+ await writePromise ( 'cmd' ) ;
521
+ await assertPromptInput ( 'cmd|' ) ;
522
+
523
+ await writePromise ( '\x1b[10C' ) ;
524
+ await assertPromptInput ( 'cmd|' ) ;
525
+ } ) ;
526
+
527
+ test ( 'whitespace preservation in cursor calculation' , async ( ) => {
528
+ await writePromise ( '$ ' ) ;
529
+ fireCommandStart ( ) ;
530
+ await assertPromptInput ( '|' ) ;
531
+
532
+ await writePromise ( 'ls -la' ) ;
533
+ await assertPromptInput ( 'ls -la|' ) ;
534
+
535
+ await writePromise ( '\x1b[3D' ) ;
536
+ await assertPromptInput ( 'ls |-la' ) ;
537
+
538
+ await writePromise ( '\x1b[3D' ) ;
539
+ await assertPromptInput ( 'ls| -la' ) ;
540
+
541
+ await writePromise ( '\x1b[2C' ) ;
542
+ await assertPromptInput ( 'ls | -la' ) ;
543
+ } ) ;
544
+
494
545
test ( 'delete whitespace with backspace' , async ( ) => {
495
546
await writePromise ( '$ ' ) ;
496
547
fireCommandStart ( ) ;
0 commit comments