@@ -394,56 +394,6 @@ setNonEnumerableReadOnly( MultilineHandler.prototype, '_triggerMultiline', funct
394
394
this . _rli . line = this . _rli . line . substring ( 0 , this . _rli . cursor ) ;
395
395
} ) ;
396
396
397
- /**
398
- * Checks if the command is incomplete and a multi-line input.
399
- *
400
- * @private
401
- * @name _isMultilineInput
402
- * @memberof MultilineHandler.prototype
403
- * @type {Function }
404
- * @param {string } cmd - command
405
- * @returns {boolean } boolean indicating whether the command is a multi-line input
406
- */
407
- setNonEnumerableReadOnly ( MultilineHandler . prototype , '_isMultilineInput' , function isMultilineInput ( cmd ) {
408
- var node ;
409
- var tmp ;
410
- var ast ;
411
-
412
- debug ( 'Attempting to detect multi-line input...' ) ;
413
- if ( RE_WHITESPACE . test ( cmd ) ) {
414
- debug ( 'Multi-line input not detected.' ) ;
415
- return false ;
416
- }
417
- if ( RE_SINGLE_LINE_COMMENT . test ( cmd ) || RE_MULTI_LINE_COMMENT . test ( cmd ) ) { // eslint-disable-line max-len
418
- debug ( 'Multi-line input not detected.' ) ;
419
- return false ;
420
- }
421
- // Check if the command has valid syntax...
422
- tmp = processCommand ( cmd ) ;
423
- if ( ! ( tmp instanceof Error ) ) {
424
- debug ( 'Multi-line input not detected.' ) ;
425
- return false ;
426
- }
427
- if ( hasMultilineError ( cmd , AOPTS ) ) {
428
- debug ( 'Detected multi-line input. Triggering multi-line mode...' ) ;
429
- return true ;
430
- }
431
- // Still possible that a user is attempting to enter an object literal across multiple lines...
432
- ast = parseLoose ( cmd , AOPTS ) ;
433
-
434
- // Check for a trailing node which is being interpreted as a block statement, as this could be an object literal...
435
- node = ast . body [ ast . body . length - 1 ] ;
436
- if ( node . type === 'BlockStatement' && node . end === ast . end ) {
437
- tmp = cmd . slice ( node . start , node . end ) ;
438
- if ( hasMultilineError ( tmp , AOPTS ) ) {
439
- debug ( 'Detected multi-line input. Triggering multi-line mode...' ) ;
440
- return true ;
441
- }
442
- }
443
- debug ( 'Multi-line input not detected.' ) ;
444
- return false ;
445
- } ) ;
446
-
447
397
/**
448
398
* Resets input buffers.
449
399
*
@@ -581,6 +531,55 @@ setNonEnumerableReadOnly( MultilineHandler.prototype, 'isPasting', function isPa
581
531
return this . _multiline . pasteMode ;
582
532
} ) ;
583
533
534
+ /**
535
+ * Checks if the command is incomplete and a multi-line input.
536
+ *
537
+ * @name isMultilineInput
538
+ * @memberof MultilineHandler.prototype
539
+ * @type {Function }
540
+ * @param {string } cmd - command
541
+ * @returns {boolean } boolean indicating whether the command is a multi-line input
542
+ */
543
+ setNonEnumerableReadOnly ( MultilineHandler . prototype , 'isMultilineInput' , function isMultilineInput ( cmd ) {
544
+ var node ;
545
+ var tmp ;
546
+ var ast ;
547
+
548
+ debug ( 'Attempting to detect multi-line input...' ) ;
549
+ if ( RE_WHITESPACE . test ( cmd ) ) {
550
+ debug ( 'Multi-line input not detected.' ) ;
551
+ return false ;
552
+ }
553
+ if ( RE_SINGLE_LINE_COMMENT . test ( cmd ) || RE_MULTI_LINE_COMMENT . test ( cmd ) ) { // eslint-disable-line max-len
554
+ debug ( 'Multi-line input not detected.' ) ;
555
+ return false ;
556
+ }
557
+ // Check if the command has valid syntax...
558
+ tmp = processCommand ( cmd ) ;
559
+ if ( ! ( tmp instanceof Error ) ) {
560
+ debug ( 'Multi-line input not detected.' ) ;
561
+ return false ;
562
+ }
563
+ if ( hasMultilineError ( cmd , AOPTS ) ) {
564
+ debug ( 'Detected multi-line input. Triggering multi-line mode...' ) ;
565
+ return true ;
566
+ }
567
+ // Still possible that a user is attempting to enter an object literal across multiple lines...
568
+ ast = parseLoose ( cmd , AOPTS ) ;
569
+
570
+ // Check for a trailing node which is being interpreted as a block statement, as this could be an object literal...
571
+ node = ast . body [ ast . body . length - 1 ] ;
572
+ if ( node . type === 'BlockStatement' && node . end === ast . end ) {
573
+ tmp = cmd . slice ( node . start , node . end ) ;
574
+ if ( hasMultilineError ( tmp , AOPTS ) ) {
575
+ debug ( 'Detected multi-line input. Triggering multi-line mode...' ) ;
576
+ return true ;
577
+ }
578
+ }
579
+ debug ( 'Multi-line input not detected.' ) ;
580
+ return false ;
581
+ } ) ;
582
+
584
583
/**
585
584
* Processes input line data.
586
585
*
@@ -737,9 +736,10 @@ setNonEnumerableReadOnly( MultilineHandler.prototype, 'beforeKeypress', function
737
736
case 'return' :
738
737
cmd = copy ( this . _cmd ) ;
739
738
cmd [ this . _lineIndex ] = this . _rli . line ;
739
+ this . _lines [ this . _lineIndex ] = this . _rli . line ;
740
740
741
741
// If we are in paste mode or the command is incomplete, trigger multi-line mode...
742
- if ( ! this . _multiline . pasteMode && ! this . _isMultilineInput ( cmd . join ( '\n' ) ) ) {
742
+ if ( ! this . _multiline . pasteMode && ! this . isMultilineInput ( cmd . join ( '\n' ) ) ) {
743
743
this . _ttyWrite . call ( this . _rli , data , key ) ;
744
744
return ;
745
745
}
0 commit comments