-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): apps with many resources scroll resource output offscreen (#…
…19742) When a stack contains a lot of resources, the RewritableBlock size becomes larger than the terminal screen, pushing the output offscreen and making it so the user has to scroll to see new output. This change adjusts the size of the RewritableBlock so that the maximum height it can be is the window height (with one line padding) so that the output never moves offscreen. It also removes the extra lines at the end of the output so that the deployment summary doesn't have a bunch of blank lines before it. Fixes #19160 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
1 parent
a2ac36e
commit 053d22c
Showing
3 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { RewritableBlock } from '../../../lib/api/util/display'; | ||
import { stderr } from '../console-listener'; | ||
|
||
|
||
describe('Rewritable Block Tests', () => { | ||
let block: RewritableBlock; | ||
beforeEach(() => { | ||
block = new RewritableBlock(process.stderr); | ||
process.stderr.rows = 80; | ||
}); | ||
|
||
test('displayLines writes maximum lines based on rows if there are more lines than rows', () => { | ||
const lines = Array.from(Array(100).keys()).map(line => line.toString()); | ||
const output = stderr.inspectSync(() => { | ||
block.displayLines(lines); | ||
}); | ||
|
||
expect(output.length).toEqual(block.height!); | ||
}); | ||
|
||
test('displayLines writes maximum lines based on lines length if there are less lines than rows', () => { | ||
const lines = Array.from(Array(45).keys()).map(line => line.toString()); | ||
const output = stderr.inspectSync(() => { | ||
block.displayLines(lines); | ||
}); | ||
|
||
expect(output.length).toEqual(46); | ||
}); | ||
|
||
test('displayLines writes maximum lines based on lines length if rows is undefined', () => { | ||
const lines = Array.from(Array(5).keys()).map(line => line.toString()); | ||
process.stderr.rows = undefined; | ||
const output = stderr.inspectSync(() => { | ||
block.displayLines(lines); | ||
}); | ||
|
||
expect(output.length).toEqual(6); | ||
}); | ||
}); |