-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: add note to tty.WriteStream event 'resize' on Windows #13576
Closed
Closed
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6da59fe
doc: note 'resize' event unreliability on Windows
Dean-Coakley a45bd1d
doc: correct 'resize' event note
Dean-Coakley 84db75d
doc: add more detail on note
Dean-Coakley 63fa375
doc: correct char limit
Dean-Coakley 86dfd24
doc: add more detail on note
Dean-Coakley 192a56f
doc: fix details on note
Dean-Coakley 784055f
doc: fix err on resume note
Dean-Coakley 05ce78a
doc: remove backslash
Dean-Coakley 5944bf0
doc: merge note paragraphs
Dean-Coakley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the console buffer height is changed, the event will also triggered. The buffer is not shrinked when downsizing widow, so it can look like changing height is ignored. If however one sets buffer height to something small in the options and then increase window height the event will be triggered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bzoz that seems like a lot of information, could you suggest the exact wording you want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Windows the console size is the virtual buffer size, not the size of the console window itself. If you shrink window height, the buffer size will remain the same, so no event will be fired. If you enlarge window enough that it will be higher than the buffer, Windows will update the buffer size and event will be signaled.
On Windows the event reliably detected only if the console is read (e.g.
process.stdin.resume();
orprocess.stdin.on('data',...)
) in raw mode.If the console is not read, or is read in line mode, this event can still be signaled. This will happen if a terminal sequence that moves the cursor is used. Calling
process.stdin._refreshSize()
will also trigger the event if the console size has been changed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more clarification: although the event is signaled only when the buffer height is changed and not the window size, Node.js reports the console window height, not the height of the buffer itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bzoz so you think the
**Note:**
should look like this?That seems like a massive amount of info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I think there is too much detail in this note. It would also make
._refreshSize()
somewhat documented function. I propose this:Note: On Windows
resize
events will be emitted only ifstdin
is unpaused (by a call toresume()
or by addingdata
listener) and in raw mode. It can be also triggered if terminal control sequence that moves the cursor is written to the screen.Note: On Windows when changing console height the
resize
event will be signaled only if console screen buffer height was also changed. For example shrinking the console window height will not cause theresize
event to be emitted. Increasing the console window height will only be registered when new console window height is greater than current console buffer size.