File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,10 +36,17 @@ export default class LocalEchoController {
3636 this . _cursor = 0 ;
3737 this . _activePrompt = null ;
3838 this . _activeCharPrompt = null ;
39+ this . _termSize = {
40+ cols : 0 ,
41+ rows : 0 ,
42+ } ;
3943
4044 this . _disposables = [ ] ;
4145
42- if ( term ) this . attach ( ) ;
46+ if ( term ) {
47+ if ( term . loadAddon ) term . loadAddon ( this ) ;
48+ else this . attach ( ) ;
49+ }
4350 }
4451
4552 // xterm.js new plugin API:
@@ -59,16 +66,26 @@ export default class LocalEchoController {
5966 * Detach the controller from the terminal
6067 */
6168 detach ( ) {
62- this . _disposables . forEach ( d => d . dispose ( ) ) ;
63- this . _disposables = [ ] ;
69+ if ( this . term . off ) {
70+ this . term . off ( "data" , this . _handleTermData ) ;
71+ this . term . off ( "resize" , this . _handleTermResize ) ;
72+ } else {
73+ this . _disposables . forEach ( d => d . dispose ( ) ) ;
74+ this . _disposables = [ ] ;
75+ }
6476 }
6577
6678 /**
6779 * Attach controller to the terminal, handling events
6880 */
6981 attach ( ) {
70- this . _disposables . push ( this . term . onData ( this . _handleTermData ) ) ;
71- this . _disposables . push ( this . term . onResize ( this . _handleTermResize ) ) ;
82+ if ( this . term . on ) {
83+ this . term . on ( "data" , this . _handleTermData ) ;
84+ this . term . on ( "resize" , this . _handleTermResize ) ;
85+ } else {
86+ this . _disposables . push ( this . term . onData ( this . _handleTermData ) ) ;
87+ this . _disposables . push ( this . term . onResize ( this . _handleTermResize ) ) ;
88+ }
7289 this . _termSize = {
7390 cols : this . term . cols ,
7491 rows : this . term . rows ,
You can’t perform that action at this time.
0 commit comments