doc: add note to tty.WriteStream event 'resize' on Windows#13576
doc: add note to tty.WriteStream event 'resize' on Windows#13576Dean-Coakley wants to merge 9 commits intonodejs:masterfrom
Conversation
doc/api/tty.md
Outdated
There was a problem hiding this comment.
Unrealiable→Unreliable- What exactly do you want to say? Please try to use whole sentences if possible. Do you mean that the execution of this event is unreliable on Windows?
There was a problem hiding this comment.
How about something like:
*Note:* Terminal window resize events are unreliable on Windows.
There was a problem hiding this comment.
@gibfahn As per your comment I would suggest to include a note about having to use setRawMode on Windows.
There was a problem hiding this comment.
That seems much better. Is it ok as 2 commits or do I need to squash/rebase?
doc/api/tty.md
Outdated
There was a problem hiding this comment.
I think what @bzoz was saying in #13197 (comment) is that this line is needed on Windows, which implies it isn't needed on other platforms.
The code snippet without this sample works reliably in Unix, and even with this sample it's not reliable on Windows (#13197 (comment)), so I think it's probably best to just not include this (especially if this leads to people not being able to Ctrl+C their program).
There was a problem hiding this comment.
That's correct. (as far as I know) Removed. I don't think it's necessary to mention in commit messages since I both added and removed it?
doc/api/tty.md
Outdated
There was a problem hiding this comment.
How about something like:
*Note:* Terminal window resize events are unreliable on Windows.
|
The commit message isn't bad, but it is over 50chars. Maybe: |
doc/api/tty.md
Outdated
| }); | ||
| ``` | ||
|
|
||
| *Note:* Unrealiable event handler execution on all Windows platforms. |
There was a problem hiding this comment.
This is a bit terse... can you expand this just a bit more?
There was a problem hiding this comment.
I could add something like
Event handler only is only executed when the width is changed
It was also suggested here that raw mode must be enabled but I did not find this in my own testing.
doc/api/tty.md
Outdated
| }); | ||
| ``` | ||
|
|
||
| *Note:* Unrealiable event handler execution on all Windows platforms. The Event handler is only executed for changes in the width of the window and the console must be in raw mode. |
There was a problem hiding this comment.
Unrealiable→UnreliableThe Event handler→The event handler- I would prefer @gibfahn's suggestion:
*Note:* Terminal window resize events are unreliable on Windows. The event handler is only...There is no reason not to use a whole sentence here. - Please try to limit the line length to 80 chars by breaking it into multiple lines if necessary.
There was a problem hiding this comment.
Thanks for the review. I believe I have implemented all the above!
doc/api/tty.md
Outdated
| ``` | ||
|
|
||
| *Note:* Terminal window resize events are unreliable on Windows. The event | ||
| handler is only executed for changes in the width of the window and the |
There was a problem hiding this comment.
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.
@bzoz that seems like a lot of information, could you suggest the exact wording you want?
There was a problem hiding this comment.
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(); or process.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.
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.
@bzoz so you think the **Note:** should look like this?
Note: 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(); or process.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.
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.
That seems like a massive amount of info.
There was a problem hiding this comment.
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 if stdin is unpaused (by a call to resume() or by adding data 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 the resize 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.
doc/api/tty.md
Outdated
| ``` | ||
|
|
||
| *Note:* On Windows resize events will be emitted only if stdin is unpaused | ||
| (by a call to resume() or by adding data listener) and in raw mode. It can be |
There was a problem hiding this comment.
resume() -> \resume()``
adding data -> adding a data
can be also -> can also be
doc/api/tty.md
Outdated
|
|
||
| *Note:* On Windows resize events will be emitted only if stdin is unpaused | ||
| (by a call to resume() or by adding data listener) and in raw mode. It can be | ||
| also triggered if terminal control sequence that moves the cursor is written to |
doc/api/tty.md
Outdated
| 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 |
doc/api/tty.md
Outdated
| *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 the resize event to be | ||
| emitted. Increasing the console window height will only be registered when new |
doc/api/tty.md
Outdated
| signaled only if console screen buffer height was also changed. For example | ||
| shrinking the console window height will not cause the resize 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. |
There was a problem hiding this comment.
than current -> than the current
|
LGTM with @gibfahn nits |
doc/api/tty.md
Outdated
| (by a call to resume() or by adding data listener) and in raw mode. It can be | ||
| also triggered if terminal control sequence that moves the cursor is written to | ||
| the screen. | ||
| (by a call to \resume()`` or by adding a data listener) and in raw mode. It can |
There was a problem hiding this comment.
You've changed to \resume()'', you need to have `resume()`
doc/api/tty.md
Outdated
|
|
||
| *Note:* On Windows resize events will be emitted only if stdin is unpaused | ||
| (by a call to \resume()`` or by adding a data listener) and in raw mode. It can | ||
| (by a call to `\resume()` or by adding a data listener) and in raw mode. It can |
gibfahn
left a comment
There was a problem hiding this comment.
LGTM, thanks a lot @Dean-Coakley !
|
I've opened a PR in libuv that improves the resize detection: libuv/libuv#1408. In any case this can still be landed, it will take some time before this gets landed in libuv and included in release that node will use. |
refack
left a comment
There was a problem hiding this comment.
Small nits, but they need to be addressed
doc/api/tty.md
Outdated
| }); | ||
| ``` | ||
|
|
||
| *Note:* On Windows resize events will be emitted only if stdin is unpaused |
There was a problem hiding this comment.
Tiny nit: *Note:* -> *Note*:
There was a problem hiding this comment.
Hmm...I copied this mistake from async_notes.md Should that be fixed in a separate PR?
doc/api/tty.md
Outdated
| also be triggered if a terminal control sequence that moves the cursor is written | ||
| to the screen. | ||
|
|
||
| *Note:* On Windows when changing console height the resize event will be |
There was a problem hiding this comment.
*Note:*->*Note*:- IMHO the two paragraphs could be merged:
Also, the resize event will be signaled only if the console screen buffer height was also changed...
There was a problem hiding this comment.
- Sorry, but I'm not entirely sure what you want here.
Can you paste the body of text you'd like? Or be very verbose about what should be replaced.
There was a problem hiding this comment.
*Note*: On Windows resize events will be emitted only if stdin is unpaused
(by a call to `resume()` or by adding a data listener) and in raw mode. It can
also be triggered if a terminal control sequence that moves the cursor is
written to the screen. Also, the resize event will only be signaled if the
console screen buffer height was also changed. For example shrinking the
console window height will not cause the resize event to be emitted. Increasing
the console window height will only be registered when the new console window
height is greater than the current console buffer size.
- Check that it is still true (the word
alsoimplies both conditions need to be met) - See if you like it. This one is just a suggestion.
|
@Dean-Coakley It's a good comment to have, I've been digging around this issue a bit as well. So I'm sorry to block so late in the process, but since doc changes don't get functional-tested, we only have eyeballs to validate all the tiny nits. |
|
@refack No worries about blocking at all. Hopefully my next PR will have less nits 😄 |
Don't count on it, doc changes get a lot of comments. Code goes in smoother 😉 |
PR-URL: nodejs#13576 Fixes: nodejs#13197 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
|
Landed in ff07eaa |
|
@Dean-Coakley Thank you very much 🥇 |
Fixes: #13197
Unsure how specific to be on the issue. Also looking for feedback on poor commit message.