Skip to content

Commit

Permalink
fix: don't resize terminal when hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed Aug 3, 2020
1 parent c2a3dcb commit 3b5a6e3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class XTerminalElementImpl extends HTMLElement {
// resized due to the pane resizing or due to the entire window
// resizing.
this.mainDivResizeObserver = new ResizeObserver((entries, observer) => {
const lastEntry = entries.pop()
this.mainDivContentRect = lastEntry.contentRect
this.refitTerminal()
})
this.mainDivResizeObserver.observe(this.mainDiv)
Expand Down Expand Up @@ -678,7 +680,12 @@ class XTerminalElementImpl extends HTMLElement {

refitTerminal () {
// Only refit the terminal when it is completely visible.
if (this.terminalDivInitiallyVisible) {
if (
this.terminalDivInitiallyVisible &&
this.mainDivContentRect &&
this.mainDivContentRect.width > 0 &&
this.mainDivContentRect.height > 0
) {
this.fitAddon.fit()
const geometry = this.fitAddon.proposeDimensions()
if (geometry && this.isPtyProcessRunning()) {
Expand Down

0 comments on commit 3b5a6e3

Please sign in to comment.