@@ -73,6 +73,7 @@ import { ISeparator, template } from 'vs/base/common/labels';
73
73
import { IPathService } from 'vs/workbench/services/path/common/pathService' ;
74
74
import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement' ;
75
75
import { ScrollbarVisibility } from 'vs/base/common/scrollable' ;
76
+ import { LineDataEventAddon } from 'vs/workbench/contrib/terminal/browser/addons/lineDataEventAddon' ;
76
77
77
78
// How long in milliseconds should an average frame take to render for a notification to appear
78
79
// which suggests the fallback DOM-based renderer
@@ -645,6 +646,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
645
646
} ) ;
646
647
this . _xterm = xterm ;
647
648
this . _xtermCore = ( xterm as any ) . _core as XTermCore ;
649
+ const lineDataEventAddon = new LineDataEventAddon ( ) ;
650
+ this . _xterm . loadAddon ( lineDataEventAddon ) ;
648
651
this . _updateUnicodeVersion ( ) ;
649
652
this . updateAccessibilitySupport ( ) ;
650
653
this . _terminalInstanceService . getXtermSearchConstructor ( ) . then ( addonCtor => {
@@ -655,10 +658,10 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
655
658
// onLineData events containing initialText
656
659
if ( this . _shellLaunchConfig . initialText ) {
657
660
this . _xterm . writeln ( this . _shellLaunchConfig . initialText , ( ) => {
658
- xterm . onLineFeed ( ( ) => this . _onLineFeed ( ) ) ;
661
+ lineDataEventAddon . onLineData ( e => this . _onLineData . fire ( e ) ) ;
659
662
} ) ;
660
663
} else {
661
- this . _xterm . onLineFeed ( ( ) => this . _onLineFeed ( ) ) ;
664
+ lineDataEventAddon . onLineData ( e => this . _onLineData . fire ( e ) ) ;
662
665
}
663
666
// Delay the creation of the bell listener to avoid showing the bell when the terminal
664
667
// starts up or reconnects
@@ -697,15 +700,11 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
697
700
return ;
698
701
}
699
702
703
+ if ( this . _processManager . os ) {
704
+ lineDataEventAddon . setOperatingSystem ( this . _processManager . os ) ;
705
+ }
700
706
if ( this . _processManager . os === OperatingSystem . Windows ) {
701
707
xterm . setOption ( 'windowsMode' , processTraits . requiresWindowsMode || false ) ;
702
- // Force line data to be sent when the cursor is moved, the main purpose for
703
- // this is because ConPTY will often not do a line feed but instead move the
704
- // cursor, in which case we still want to send the current line's data to tasks.
705
- xterm . parser . registerCsiHandler ( { final : 'H' } , ( ) => {
706
- this . _onCursorMove ( ) ;
707
- return false ;
708
- } ) ;
709
708
}
710
709
this . _linkManager = this . _instantiationService . createInstance ( TerminalLinkManager , xterm , this . _processManager ! ) ;
711
710
this . _areLinksReady = true ;
@@ -1075,11 +1074,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
1075
1074
this . _horizontalScrollbar = undefined ;
1076
1075
}
1077
1076
}
1078
- if ( this . _xterm ) {
1079
- const buffer = this . _xterm . buffer ;
1080
- this . _sendLineData ( buffer . active , buffer . active . baseY + buffer . active . cursorY ) ;
1081
- this . _xterm . dispose ( ) ;
1082
- }
1077
+ this . _xterm ?. dispose ( ) ;
1083
1078
1084
1079
if ( this . _pressAnyKeyToCloseListener ) {
1085
1080
this . _pressAnyKeyToCloseListener . dispose ( ) ;
@@ -1525,41 +1520,12 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
1525
1520
this . reuseTerminal ( this . _shellLaunchConfig , true ) ;
1526
1521
}
1527
1522
1528
- private _onLineFeed ( ) : void {
1529
- const buffer = this . _xterm ! . buffer ;
1530
- const newLine = buffer . active . getLine ( buffer . active . baseY + buffer . active . cursorY ) ;
1531
- if ( newLine && ! newLine . isWrapped ) {
1532
- this . _sendLineData ( buffer . active , buffer . active . baseY + buffer . active . cursorY - 1 ) ;
1533
- }
1534
- }
1535
-
1536
- private _onCursorMove ( ) : void {
1537
- const buffer = this . _xterm ! . buffer ;
1538
- this . _sendLineData ( buffer . active , buffer . active . baseY + buffer . active . cursorY ) ;
1539
- }
1540
-
1541
1523
private _onTitleChange ( title : string ) : void {
1542
1524
if ( this . isTitleSetByProcess ) {
1543
1525
this . refreshTabLabels ( title , TitleEventSource . Sequence ) ;
1544
1526
}
1545
1527
}
1546
1528
1547
- private _sendLineData ( buffer : IBuffer , lineIndex : number ) : void {
1548
- let line = buffer . getLine ( lineIndex ) ;
1549
- if ( ! line ) {
1550
- return ;
1551
- }
1552
- let lineData = line . translateToString ( true ) ;
1553
- while ( lineIndex > 0 && line . isWrapped ) {
1554
- line = buffer . getLine ( -- lineIndex ) ;
1555
- if ( ! line ) {
1556
- break ;
1557
- }
1558
- lineData = line . translateToString ( false ) + lineData ;
1559
- }
1560
- this . _onLineData . fire ( lineData ) ;
1561
- }
1562
-
1563
1529
private _onKey ( key : string , ev : KeyboardEvent ) : void {
1564
1530
const event = new StandardKeyboardEvent ( ev ) ;
1565
1531
0 commit comments