@@ -7,7 +7,7 @@ import { timeout } from 'vs/base/common/async';
7
7
import { debounce } from 'vs/base/common/decorators' ;
8
8
import { Emitter } from 'vs/base/common/event' ;
9
9
import { ILogService } from 'vs/platform/log/common/log' ;
10
- import { ICommandDetectionCapability , TerminalCapability , ITerminalCommand , IHandleCommandOptions , ICommandInvalidationRequest , CommandInvalidationReason , ISerializedCommand , ISerializedCommandDetectionCapability } from 'vs/platform/terminal/common/capabilities/capabilities' ;
10
+ import { ICommandDetectionCapability , TerminalCapability , ITerminalCommand , IHandleCommandOptions , ICommandInvalidationRequest , CommandInvalidationReason , ISerializedCommand , ISerializedCommandDetectionCapability , ITerminalOutputMatcher } from 'vs/platform/terminal/common/capabilities/capabilities' ;
11
11
12
12
// Importing types is safe in any layer
13
13
// eslint-disable-next-line local/code-import-patterns
@@ -490,7 +490,7 @@ export class CommandDetectionCapability implements ICommandDetectionCapability {
490
490
commandStartLineContent : this . _currentCommand . commandStartLineContent ,
491
491
hasOutput : ( ) => ! executedMarker ?. isDisposed && ! endMarker ?. isDisposed && ! ! ( executedMarker && endMarker && executedMarker ?. line < endMarker ! . line ) ,
492
492
getOutput : ( ) => getOutputForCommand ( executedMarker , endMarker , buffer ) ,
493
- getOutputMatch : ( outputMatcher : { lineMatcher : string | RegExp ; anchor ?: 'top' | 'bottom' ; offset ?: number ; length ?: number } ) => getOutputMatchForCommand ( executedMarker , endMarker , buffer , this . _terminal . cols , outputMatcher ) ,
493
+ getOutputMatch : ( outputMatcher : ITerminalOutputMatcher ) => getOutputMatchForCommand ( executedMarker , endMarker , buffer , this . _terminal . cols , outputMatcher ) ,
494
494
markProperties : options ?. markProperties
495
495
} ;
496
496
this . _commands . push ( newCommand ) ;
@@ -615,7 +615,7 @@ export class CommandDetectionCapability implements ICommandDetectionCapability {
615
615
exitCode : e . exitCode ,
616
616
hasOutput : ( ) => ! executedMarker ?. isDisposed && ! endMarker ?. isDisposed && ! ! ( executedMarker && endMarker && executedMarker . line < endMarker . line ) ,
617
617
getOutput : ( ) => getOutputForCommand ( executedMarker , endMarker , buffer ) ,
618
- getOutputMatch : ( outputMatcher : { lineMatcher : string | RegExp ; anchor ?: 'top' | 'bottom' ; offset ?: number ; length ?: number } ) => getOutputMatchForCommand ( executedMarker , endMarker , buffer , this . _terminal . cols , outputMatcher ) ,
618
+ getOutputMatch : ( outputMatcher : ITerminalOutputMatcher ) => getOutputMatchForCommand ( executedMarker , endMarker , buffer , this . _terminal . cols , outputMatcher ) ,
619
619
markProperties : e . markProperties
620
620
} ;
621
621
this . _commands . push ( newCommand ) ;
@@ -647,7 +647,7 @@ function getOutputForCommand(executedMarker: IMarker | undefined, endMarker: IMa
647
647
return output === '' ? undefined : output ;
648
648
}
649
649
650
- export function getOutputMatchForCommand ( executedMarker : IMarker | undefined , endMarker : IMarker | undefined , buffer : IBuffer , cols : number , outputMatcher : { lineMatcher : string | RegExp ; anchor ?: 'top' | 'bottom' ; offset ?: number ; length ?: number } ) : RegExpMatchArray | undefined {
650
+ export function getOutputMatchForCommand ( executedMarker : IMarker | undefined , endMarker : IMarker | undefined , buffer : IBuffer , cols : number , outputMatcher : ITerminalOutputMatcher ) : RegExpMatchArray | undefined {
651
651
if ( ! executedMarker || ! endMarker ) {
652
652
return undefined ;
653
653
}
@@ -659,7 +659,13 @@ export function getOutputMatchForCommand(executedMarker: IMarker | undefined, en
659
659
const lines : string [ ] = [ ] ;
660
660
if ( outputMatcher . anchor === 'bottom' ) {
661
661
for ( let i = endLine - ( outputMatcher . offset || 0 ) ; i >= startLine ; i -- ) {
662
- lines . unshift ( getXtermLineContent ( buffer , i , i , cols ) ) ;
662
+ let wrappedLineStart = i ;
663
+ const wrappedLineEnd = i ;
664
+ while ( wrappedLineStart >= startLine && buffer . getLine ( wrappedLineStart ) ?. isWrapped ) {
665
+ wrappedLineStart -- ;
666
+ }
667
+ i = wrappedLineStart ;
668
+ lines . unshift ( getXtermLineContent ( buffer , wrappedLineStart , wrappedLineEnd , cols ) ) ;
663
669
if ( lines . length > linesToCheck ) {
664
670
lines . pop ( ) ;
665
671
}
@@ -670,7 +676,13 @@ export function getOutputMatchForCommand(executedMarker: IMarker | undefined, en
670
676
}
671
677
} else {
672
678
for ( let i = startLine + ( outputMatcher . offset || 0 ) ; i < endLine ; i ++ ) {
673
- lines . push ( getXtermLineContent ( buffer , i , i , cols ) ) ;
679
+ const wrappedLineStart = i ;
680
+ let wrappedLineEnd = i ;
681
+ while ( wrappedLineEnd + 1 < endLine && buffer . getLine ( wrappedLineEnd + 1 ) ?. isWrapped ) {
682
+ wrappedLineEnd ++ ;
683
+ }
684
+ i = wrappedLineEnd ;
685
+ lines . push ( getXtermLineContent ( buffer , wrappedLineStart , wrappedLineEnd , cols ) ) ;
674
686
if ( lines . length === linesToCheck ) {
675
687
lines . shift ( ) ;
676
688
}
0 commit comments