Skip to content

Commit

Permalink
fix: fix resize when switching docks
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed Jul 27, 2020
1 parent 8f7cd83 commit 5ce066b
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 64 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ module.exports = {
'comma-dangle': ['error', 'always-multiline'],
indent: ['error', 'tab', { SwitchCase: 1 }],
'no-tabs': ['error', { allowIndentationTabs: true }],
'no-console': 'warn',
},
}
13 changes: 0 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
},
"dependencies": {
"deep-object-diff": "^1.1.0",
"element-resize-detector": "^1.2.1",
"fs-extra": "^9.0.1",
"marked": "^1.1.1",
"node-pty-prebuilt-multiarch": "^0.9.0",
Expand Down
1 change: 1 addition & 0 deletions spec/custom-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import { createRunner } from 'atom-jasmine3-test-runner'

module.exports = createRunner({}, () => {
// eslint-disable-next-line no-console
const warn = console.warn.bind(console)
beforeEach(() => {
spyOn(console, 'warn').and.callFake((...args) => {
Expand Down
67 changes: 30 additions & 37 deletions spec/element-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1592,21 +1592,14 @@ describe('XTerminalElement', () => {

it('refitTerminal() terminal not visible', () => {
spyOn(this.element.fitAddon, 'proposeDimensions')
this.element.terminalDivIntersectionRatio = 0.0
this.element.refitTerminal()
expect(this.element.fitAddon.proposeDimensions).not.toHaveBeenCalled()
})

it('refitTerminal() terminal partially visible', () => {
spyOn(this.element.fitAddon, 'proposeDimensions')
this.element.terminalDivIntersectionRatio = 0.5
this.element.terminalDivInitiallyVisible = false
this.element.refitTerminal()
expect(this.element.fitAddon.proposeDimensions).not.toHaveBeenCalled()
})

it('refitTerminal() terminal completely visible', () => {
spyOn(this.element.fitAddon, 'proposeDimensions').and.returnValue(null)
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.refitTerminal()
expect(this.element.fitAddon.proposeDimensions).toHaveBeenCalled()
})
Expand All @@ -1617,7 +1610,7 @@ describe('XTerminalElement', () => {
rows: this.element.terminal.rows,
})
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = false
this.element.refitTerminal()
expect(this.element.terminal.resize).not.toHaveBeenCalled()
Expand All @@ -1629,7 +1622,7 @@ describe('XTerminalElement', () => {
rows: this.element.terminal.rows,
})
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = false
this.element.refitTerminal()
expect(this.element.terminal.resize).toHaveBeenCalled()
Expand All @@ -1641,7 +1634,7 @@ describe('XTerminalElement', () => {
rows: this.element.terminal.rows + 1,
})
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = false
this.element.refitTerminal()
expect(this.element.terminal.resize).toHaveBeenCalled()
Expand All @@ -1653,7 +1646,7 @@ describe('XTerminalElement', () => {
rows: this.element.terminal.rows + 1,
})
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = false
this.element.refitTerminal()
expect(this.element.terminal.resize).toHaveBeenCalled()
Expand All @@ -1665,7 +1658,7 @@ describe('XTerminalElement', () => {
rows: this.element.terminal.rows - 1,
})
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = false
this.element.refitTerminal()
expect(this.element.terminal.resize).toHaveBeenCalled()
Expand All @@ -1677,7 +1670,7 @@ describe('XTerminalElement', () => {
rows: this.element.terminal.rows - 1,
})
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = false
this.element.refitTerminal()
expect(this.element.terminal.resize).toHaveBeenCalled()
Expand All @@ -1689,7 +1682,7 @@ describe('XTerminalElement', () => {
rows: this.element.ptyProcessRows,
})
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = true
this.element.refitTerminal()
expect(this.element.ptyProcess.resize).not.toHaveBeenCalled()
Expand All @@ -1701,7 +1694,7 @@ describe('XTerminalElement', () => {
rows: this.element.ptyProcessRows,
})
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = true
this.element.refitTerminal()
expect(this.element.ptyProcess.resize).toHaveBeenCalled()
Expand All @@ -1713,7 +1706,7 @@ describe('XTerminalElement', () => {
rows: this.element.ptyProcessRows + 1,
})
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = true
this.element.refitTerminal()
expect(this.element.ptyProcess.resize).toHaveBeenCalled()
Expand All @@ -1725,7 +1718,7 @@ describe('XTerminalElement', () => {
rows: this.element.ptyProcessRows + 1,
})
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = true
this.element.refitTerminal()
expect(this.element.ptyProcess.resize).toHaveBeenCalled()
Expand All @@ -1737,7 +1730,7 @@ describe('XTerminalElement', () => {
rows: this.element.ptyProcessRows,
})
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = true
this.element.refitTerminal()
expect(this.element.ptyProcess.resize).toHaveBeenCalled()
Expand All @@ -1749,7 +1742,7 @@ describe('XTerminalElement', () => {
rows: this.element.ptyProcessRows - 1,
})
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = true
this.element.refitTerminal()
expect(this.element.ptyProcess.resize).toHaveBeenCalled()
Expand All @@ -1761,7 +1754,7 @@ describe('XTerminalElement', () => {
rows: this.element.ptyProcessRows - 1,
})
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = true
this.element.refitTerminal()
expect(this.element.ptyProcess.resize).toHaveBeenCalled()
Expand All @@ -1774,7 +1767,7 @@ describe('XTerminalElement', () => {
}
spyOn(this.element.fitAddon, 'proposeDimensions').and.returnValue(expected)
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = true
this.element.refitTerminal()
expect(this.element.ptyProcess.resize).toHaveBeenCalledWith(expected.cols, expected.rows)
Expand All @@ -1787,7 +1780,7 @@ describe('XTerminalElement', () => {
}
spyOn(this.element.fitAddon, 'proposeDimensions').and.returnValue(expected)
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = true
this.element.refitTerminal()
expect(this.element.ptyProcess.resize).toHaveBeenCalledWith(expected.cols, expected.rows)
Expand All @@ -1800,7 +1793,7 @@ describe('XTerminalElement', () => {
}
spyOn(this.element.fitAddon, 'proposeDimensions').and.returnValue(expected)
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = true
this.element.refitTerminal()
expect(this.element.ptyProcess.resize).toHaveBeenCalledWith(expected.cols, expected.rows)
Expand All @@ -1813,7 +1806,7 @@ describe('XTerminalElement', () => {
}
spyOn(this.element.fitAddon, 'proposeDimensions').and.returnValue(expected)
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = true
this.element.refitTerminal()
expect(this.element.ptyProcess.resize).toHaveBeenCalledWith(expected.cols, expected.rows)
Expand All @@ -1826,7 +1819,7 @@ describe('XTerminalElement', () => {
}
spyOn(this.element.fitAddon, 'proposeDimensions').and.returnValue(expected)
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = true
this.element.refitTerminal()
expect(this.element.ptyProcess.resize).toHaveBeenCalledWith(expected.cols, expected.rows)
Expand All @@ -1839,7 +1832,7 @@ describe('XTerminalElement', () => {
}
spyOn(this.element.fitAddon, 'proposeDimensions').and.returnValue(expected)
spyOn(this.element.terminal, 'resize')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.ptyProcessRunning = true
this.element.refitTerminal()
expect(this.element.ptyProcess.resize).toHaveBeenCalledWith(expected.cols, expected.rows)
Expand Down Expand Up @@ -2224,7 +2217,7 @@ describe('XTerminalElement', () => {

it('applyPendingTerminalProfileOptions() terminal not visible', () => {
spyOn(this.element, 'refitTerminal')
this.element.terminalDivIntersectionRatio = 0.0
this.element.terminalDivInitiallyVisible = false
this.element.applyPendingTerminalProfileOptions()
expect(this.element.refitTerminal).not.toHaveBeenCalled()
})
Expand All @@ -2234,7 +2227,7 @@ describe('XTerminalElement', () => {
spyOn(this.element, 'setMainBackgroundColor')
spyOn(this.element, 'restartPtyProcess')
spyOn(this.element.terminal, 'setOption')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.applyPendingTerminalProfileOptions()
expect(this.element.setMainBackgroundColor).toHaveBeenCalled()
expect(this.element.terminal.setOption).not.toHaveBeenCalled()
Expand All @@ -2247,7 +2240,7 @@ describe('XTerminalElement', () => {
spyOn(this.element, 'setMainBackgroundColor')
spyOn(this.element, 'restartPtyProcess')
spyOn(this.element.terminal, 'setOption')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.pendingTerminalProfileOptions.xtermOptions = {
cursorBlink: true,
}
Expand All @@ -2263,7 +2256,7 @@ describe('XTerminalElement', () => {
spyOn(this.element, 'setMainBackgroundColor')
spyOn(this.element, 'restartPtyProcess')
spyOn(this.element.terminal, 'setOption')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.pendingTerminalProfileOptions.command = 'somecommand'
this.element.applyPendingTerminalProfileOptions()
expect(this.element.setMainBackgroundColor).toHaveBeenCalled()
Expand All @@ -2277,7 +2270,7 @@ describe('XTerminalElement', () => {
spyOn(this.element, 'setMainBackgroundColor')
spyOn(this.element, 'restartPtyProcess')
spyOn(this.element.terminal, 'setOption')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.pendingTerminalProfileOptions.xtermOptions = {
cursorBlink: true,
}
Expand All @@ -2291,7 +2284,7 @@ describe('XTerminalElement', () => {

it('applyPendingTerminalProfileOptions() terminal not visible pending xtermOptions and pty changes kept', () => {
spyOn(this.element, 'refitTerminal')
this.element.terminalDivIntersectionRatio = 0.0
this.element.terminalDivInitiallyVisible = false
this.element.pendingTerminalProfileOptions.xtermOptions = {
cursorBlink: true,
}
Expand All @@ -2307,7 +2300,7 @@ describe('XTerminalElement', () => {

it('applyPendingTerminalProfileOptions() terminal visible pending xtermOptions and pty changes removed', () => {
spyOn(this.element, 'refitTerminal')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.pendingTerminalProfileOptions.xtermOptions = {
cursorBlink: true,
}
Expand All @@ -2318,7 +2311,7 @@ describe('XTerminalElement', () => {

it('applyPendingTerminalProfileOptions() terminal not visible x-terminal options removed', () => {
spyOn(this.element, 'refitTerminal')
this.element.terminalDivIntersectionRatio = 0.0
this.element.terminalDivInitiallyVisible = false
this.element.pendingTerminalProfileOptions.leaveOpenAfterExit = true
this.element.pendingTerminalProfileOptions.relaunchTerminalOnStartup = true
this.element.pendingTerminalProfileOptions.title = 'foo'
Expand All @@ -2328,7 +2321,7 @@ describe('XTerminalElement', () => {

it('applyPendingTerminalProfileOptions() terminal visible x-terminal options removed', () => {
spyOn(this.element, 'refitTerminal')
this.element.terminalDivIntersectionRatio = 1.0
this.element.terminalDivInitiallyVisible = true
this.element.pendingTerminalProfileOptions.leaveOpenAfterExit = true
this.element.pendingTerminalProfileOptions.relaunchTerminalOnStartup = true
this.element.pendingTerminalProfileOptions.title = 'foo'
Expand Down
Loading

0 comments on commit 5ce066b

Please sign in to comment.