未验证 提交 c3f12631 编写于 作者: D Daniel Imms 提交者: GitHub

Merge pull request #128700 from microsoft/tyriar/r158_128342

Fallback to 80x30 dimensions in terminal
......@@ -79,7 +79,10 @@ const enum Constants {
* terminal process. This period helps ensure the terminal has good initial dimensions to work
* with if it's going to be a foreground terminal.
*/
WaitForContainerThreshold = 100
WaitForContainerThreshold = 100,
DefaultCols = 80,
DefaultRows = 30,
}
let xtermConstructor: Promise<typeof XTermTerminal> | undefined;
......@@ -538,9 +541,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
const editorOptions = this._configurationService.getValue<IEditorOptions>('editor');
const xterm = new Terminal({
// TODO: Replace null with undefined when https://github.com/xtermjs/xterm.js/issues/3329 is resolved
cols: this._cols || null as any,
rows: this._rows || null as any,
cols: this._cols || Constants.DefaultCols,
rows: this._rows || Constants.DefaultRows,
altClickMovesCursor: config.altClickMovesCursor && editorOptions.multiCursorModifier === 'alt',
scrollback: config.scrollback,
theme: this._getXtermTheme(),
......@@ -1058,6 +1060,11 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this._wrapperElement.classList.toggle('active', visible);
}
if (visible && this._xterm && this._xtermCore) {
// Resize to re-evaluate dimensions, this will ensure when switching to a terminal it is
// using the most up to date dimensions (eg. when terminal is created in the background
// using cached dimensions of a split terminal).
this._resize();
// Trigger a manual scroll event which will sync the viewport and scroll bar. This is
// necessary if the number of rows in the terminal has decreased while it was in the
// background since scrollTop changes take no effect but the terminal's position does
......@@ -1159,8 +1166,15 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
if (this._isDisposed) {
return;
}
// Re-evaluate dimensions if the container has been set since the xterm instance was created
if (this._container && this._cols === 0 && this._rows === 0) {
this._initDimensions();
this._xterm?.resize(this._cols || Constants.DefaultCols, this._rows || Constants.DefaultRows);
}
const hadIcon = !!this.shellLaunchConfig.icon;
await this._processManager.createProcess(this._shellLaunchConfig, this._cols, this._rows, this._accessibilityService.isScreenReaderOptimized()).then(error => {
await this._processManager.createProcess(this._shellLaunchConfig, this._cols || Constants.DefaultCols, this._rows || Constants.DefaultRows, this._accessibilityService.isScreenReaderOptimized()).then(error => {
if (error) {
this._onProcessExit(error);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册