@@ -79,7 +79,10 @@ const enum Constants {
79
79
* terminal process. This period helps ensure the terminal has good initial dimensions to work
80
80
* with if it's going to be a foreground terminal.
81
81
*/
82
- WaitForContainerThreshold = 100
82
+ WaitForContainerThreshold = 100 ,
83
+
84
+ DefaultCols = 80 ,
85
+ DefaultRows = 30 ,
83
86
}
84
87
85
88
let xtermConstructor : Promise < typeof XTermTerminal > | undefined ;
@@ -538,9 +541,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
538
541
const editorOptions = this . _configurationService . getValue < IEditorOptions > ( 'editor' ) ;
539
542
540
543
const xterm = new Terminal ( {
541
- // TODO: Replace null with undefined when https://github.com/xtermjs/xterm.js/issues/3329 is resolved
542
- cols : this . _cols || null as any ,
543
- rows : this . _rows || null as any ,
544
+ cols : this . _cols || Constants . DefaultCols ,
545
+ rows : this . _rows || Constants . DefaultRows ,
544
546
altClickMovesCursor : config . altClickMovesCursor && editorOptions . multiCursorModifier === 'alt' ,
545
547
scrollback : config . scrollback ,
546
548
theme : this . _getXtermTheme ( ) ,
@@ -1058,6 +1060,11 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
1058
1060
this . _wrapperElement . classList . toggle ( 'active' , visible ) ;
1059
1061
}
1060
1062
if ( visible && this . _xterm && this . _xtermCore ) {
1063
+ // Resize to re-evaluate dimensions, this will ensure when switching to a terminal it is
1064
+ // using the most up to date dimensions (eg. when terminal is created in the background
1065
+ // using cached dimensions of a split terminal).
1066
+ this . _resize ( ) ;
1067
+
1061
1068
// Trigger a manual scroll event which will sync the viewport and scroll bar. This is
1062
1069
// necessary if the number of rows in the terminal has decreased while it was in the
1063
1070
// background since scrollTop changes take no effect but the terminal's position does
@@ -1159,8 +1166,15 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
1159
1166
if ( this . _isDisposed ) {
1160
1167
return ;
1161
1168
}
1169
+
1170
+ // Re-evaluate dimensions if the container has been set since the xterm instance was created
1171
+ if ( this . _container && this . _cols === 0 && this . _rows === 0 ) {
1172
+ this . _initDimensions ( ) ;
1173
+ this . _xterm ?. resize ( this . _cols || Constants . DefaultCols , this . _rows || Constants . DefaultRows ) ;
1174
+ }
1175
+
1162
1176
const hadIcon = ! ! this . shellLaunchConfig . icon ;
1163
- await this . _processManager . createProcess ( this . _shellLaunchConfig , this . _cols , this . _rows , this . _accessibilityService . isScreenReaderOptimized ( ) ) . then ( error => {
1177
+ await this . _processManager . createProcess ( this . _shellLaunchConfig , this . _cols || Constants . DefaultCols , this . _rows || Constants . DefaultRows , this . _accessibilityService . isScreenReaderOptimized ( ) ) . then ( error => {
1164
1178
if ( error ) {
1165
1179
this . _onProcessExit ( error ) ;
1166
1180
}
0 commit comments