@@ -154,7 +154,6 @@ export class CommandDetectionCapability extends Disposable implements ICommandDe
154
154
} ;
155
155
this . _register ( this . _terminal . onResize ( e => this . _handleResize ( e ) ) ) ;
156
156
this . _register ( this . _terminal . onCursorMove ( ( ) => this . _handleCursorMove ( ) ) ) ;
157
- this . _register ( this . _terminal . onData ( ( ) => this . _handleInput ( ) ) ) ;
158
157
}
159
158
160
159
private _handleResize ( e : { cols : number ; rows : number } ) {
@@ -208,10 +207,6 @@ export class CommandDetectionCapability extends Disposable implements ICommandDe
208
207
this . _cwd = value ;
209
208
}
210
209
211
- setPromptHeight ( value : number ) {
212
- this . _currentCommand . promptHeight = value ;
213
- }
214
-
215
210
setIsWindowsPty ( value : boolean ) {
216
211
if ( value && ! ( this . _ptyHeuristics . value instanceof WindowsPtyHeuristics ) ) {
217
212
const that = this ;
@@ -285,10 +280,6 @@ export class CommandDetectionCapability extends Disposable implements ICommandDe
285
280
return undefined ;
286
281
}
287
282
288
- private _handleInput ( ) : void {
289
- this . _ptyHeuristics . value . handleInput ( ) ;
290
- }
291
-
292
283
handlePromptStart ( options ?: IHandleCommandOptions ) : void {
293
284
// Adjust the last command's finished marker when needed. The standard position for the
294
285
// finished marker `D` to appear is at the same position as the following prompt started
@@ -508,8 +499,6 @@ class UnixPtyHeuristics extends Disposable {
508
499
} ) ) ;
509
500
}
510
501
511
- handleInput ( ) { }
512
-
513
502
handleCommandStart ( options ?: IHandleCommandOptions ) {
514
503
this . _hooks . commitCommandFinished ( ) ;
515
504
@@ -663,28 +652,6 @@ class WindowsPtyHeuristics extends Disposable {
663
652
}
664
653
}
665
654
666
- /**
667
- * Attempt to adjust the command start marker when input is handled for the first time.
668
- */
669
- handleInput ( ) {
670
- const currentY = this . _terminal . buffer . active . baseY + this . _terminal . buffer . active . cursorY ;
671
-
672
- const hasWrappingInPrompt = Array . from ( { length : ( this . _capability . currentCommand . promptHeight ?? 0 ) + 1 } , ( _ , i ) => currentY - i ) . find ( y => this . _terminal . buffer . active . getLine ( y ) ?. isWrapped ) !== undefined ;
673
- const hasActiveCommand = this . _capability . currentCommand . commandStartX !== undefined && this . _capability . currentCommand . commandExecutedX === undefined ;
674
- const hasAdjusted = this . _capability . currentCommand . isAdjusted === true || this . _capability . currentCommand . isInputAdjusted === true ;
675
-
676
- if ( ! hasActiveCommand || hasAdjusted || hasWrappingInPrompt ) {
677
- return ;
678
- }
679
- this . _capability . currentCommand . isInputAdjusted = true ;
680
- this . _logService . debug ( 'CommandDetectionCapability#handleInput attempting start marker adjustment' ) ;
681
-
682
- this . _tryAdjustCommandStartMarkerScannedLineCount = 0 ;
683
- this . _tryAdjustCommandStartMarkerPollCount = 0 ;
684
- this . _tryAdjustCommandStartMarkerScheduler = new RunOnceScheduler ( ( ) => this . _tryAdjustCommandStartMarker ( this . _terminal . registerMarker ( 0 ) ! ) , AdjustCommandStartMarkerConstants . Interval ) ;
685
- this . _tryAdjustCommandStartMarkerScheduler . schedule ( ) ;
686
- }
687
-
688
655
handleCommandStart ( ) {
689
656
this . _capability . currentCommand . commandStartX = this . _terminal . buffer . active . cursorX ;
690
657
@@ -746,24 +713,21 @@ class WindowsPtyHeuristics extends Disposable {
746
713
if ( prompt ) {
747
714
const adjustedPrompt = typeof prompt === 'string' ? prompt : prompt . prompt ;
748
715
this . _capability . currentCommand . commandStartMarker = this . _terminal . registerMarker ( 0 ) ! ;
749
-
750
- // Adjust the prompt start marker to the command start marker
751
- this . _logService . debug ( 'CommandDetectionCapability#_tryAdjustCommandStartMarker adjusted promptStart' , `${ this . _capability . currentCommand . promptStartMarker ?. line } -> ${ this . _capability . currentCommand . commandStartMarker . line } ` ) ;
752
- this . _capability . currentCommand . promptStartMarker ?. dispose ( ) ;
753
- this . _capability . currentCommand . promptStartMarker = cloneMarker ( this . _terminal , this . _capability . currentCommand . commandStartMarker , - ( ( this . _capability . currentCommand . promptHeight ?? 1 ) - 1 ) ) ;
754
-
755
- // Adjust the last command if it's not in the same position as the following
756
- // prompt start marker
757
- const lastCommand = this . _capability . commands . at ( - 1 ) ;
758
- if ( lastCommand && this . _capability . currentCommand . commandStartMarker . line !== lastCommand . endMarker ?. line ) {
759
- lastCommand . endMarker ?. dispose ( ) ;
760
- lastCommand . endMarker = cloneMarker ( this . _terminal , this . _capability . currentCommand . commandStartMarker , - ( ( this . _capability . currentCommand . promptHeight ?? 1 ) - 1 ) ) ;
716
+ if ( typeof prompt === 'object' && prompt . likelySingleLine ) {
717
+ this . _logService . debug ( 'CommandDetectionCapability#_tryAdjustCommandStartMarker adjusted promptStart' , `${ this . _capability . currentCommand . promptStartMarker ?. line } -> ${ this . _capability . currentCommand . commandStartMarker . line } ` ) ;
718
+ this . _capability . currentCommand . promptStartMarker ?. dispose ( ) ;
719
+ this . _capability . currentCommand . promptStartMarker = cloneMarker ( this . _terminal , this . _capability . currentCommand . commandStartMarker ) ;
720
+ // Adjust the last command if it's not in the same position as the following
721
+ // prompt start marker
722
+ const lastCommand = this . _capability . commands . at ( - 1 ) ;
723
+ if ( lastCommand && this . _capability . currentCommand . commandStartMarker . line !== lastCommand . endMarker ?. line ) {
724
+ lastCommand . endMarker ?. dispose ( ) ;
725
+ lastCommand . endMarker = cloneMarker ( this . _terminal , this . _capability . currentCommand . commandStartMarker ) ;
726
+ }
761
727
}
762
-
763
728
// use the regex to set the position as it's possible input has occurred
764
729
this . _capability . currentCommand . commandStartX = adjustedPrompt . length ;
765
730
this . _logService . debug ( 'CommandDetectionCapability#_tryAdjustCommandStartMarker adjusted commandStart' , `${ start . line } -> ${ this . _capability . currentCommand . commandStartMarker . line } :${ this . _capability . currentCommand . commandStartX } ` ) ;
766
- this . _capability . currentCommand . isAdjusted = true ;
767
731
this . _flushPendingHandleCommandStartTask ( ) ;
768
732
return ;
769
733
}
@@ -1085,7 +1049,5 @@ function getXtermLineContent(buffer: IBuffer, lineStart: number, lineEnd: number
1085
1049
}
1086
1050
1087
1051
function cloneMarker ( xterm : Terminal , marker : IXtermMarker , offset : number = 0 ) : IXtermMarker | undefined {
1088
- const cursorY = xterm . buffer . active . baseY + xterm . buffer . active . cursorY ;
1089
- const cursorYOffset = marker . line - cursorY + offset ;
1090
- return xterm . registerMarker ( ( cursorY + cursorYOffset ) < 0 ? - cursorY : cursorYOffset ) ;
1052
+ return xterm . registerMarker ( marker . line - ( xterm . buffer . active . baseY + xterm . buffer . active . cursorY ) + offset ) ;
1091
1053
}
0 commit comments