Skip to content

Commit 3bea1f0

Browse files
committed
Fallback to 80x30 dimensions in terminal
This fixes an issue where when the terminal would be created without a container it initializes with 0x0 dimensions which gets set to the minimum of 2x1 instead of the expected default of 80x30 (which node-pty respects). This 80x30 is now hardcoded in VS Code. Fixes microsoft#128342
1 parent 268e9da commit 3bea1f0

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/vs/workbench/contrib/terminal/browser/terminalInstance.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ const enum Constants {
7979
* terminal process. This period helps ensure the terminal has good initial dimensions to work
8080
* with if it's going to be a foreground terminal.
8181
*/
82-
WaitForContainerThreshold = 100
82+
WaitForContainerThreshold = 100,
83+
84+
DefaultCols = 80,
85+
DefaultRows = 30,
8386
}
8487

8588
let xtermConstructor: Promise<typeof XTermTerminal> | undefined;
@@ -538,9 +541,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
538541
const editorOptions = this._configurationService.getValue<IEditorOptions>('editor');
539542

540543
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,
544546
altClickMovesCursor: config.altClickMovesCursor && editorOptions.multiCursorModifier === 'alt',
545547
scrollback: config.scrollback,
546548
theme: this._getXtermTheme(),
@@ -1159,8 +1161,15 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
11591161
if (this._isDisposed) {
11601162
return;
11611163
}
1164+
1165+
// Re-evaluate dimensions if the container has been set since the xterm instance was created
1166+
if (this._container && this._cols === 0 && this._rows === 0) {
1167+
this._initDimensions();
1168+
this._xterm?.resize(this._cols || Constants.DefaultCols, this._rows || Constants.DefaultRows);
1169+
}
1170+
11621171
const hadIcon = !!this.shellLaunchConfig.icon;
1163-
await this._processManager.createProcess(this._shellLaunchConfig, this._cols, this._rows, this._accessibilityService.isScreenReaderOptimized()).then(error => {
1172+
await this._processManager.createProcess(this._shellLaunchConfig, this._cols || Constants.DefaultCols, this._rows || Constants.DefaultRows, this._accessibilityService.isScreenReaderOptimized()).then(error => {
11641173
if (error) {
11651174
this._onProcessExit(error);
11661175
}

0 commit comments

Comments
 (0)