-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Stop auto scrolling to bottom on output #336
Conversation
@@ -2413,6 +2420,13 @@ Terminal.prototype.attachCustomKeydownHandler = function(customKeydownHandler) { | |||
* @param {KeyboardEvent} ev The keydown event to be handled. | |||
*/ | |||
Terminal.prototype.keyDown = function(ev) { | |||
// Scroll down to prompt, whenever the user presses a key. | |||
if (this.ybase !== this.ydisp) { |
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.
Should this.userScrolling
be set here?
Also I think having this at the start of keyDown
means that the DOM could be updated twice in a row, once before the key is evaluated and once after.
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.
Should
this.userScrolling
be set here?
I am not sure if it should. Strictly speaking, the user is not scrolling here. We are scrolling to bottom for them, in order to be able to see their input.
Also I think having this at the start of
keyDown
means that the DOM could be updated twice in a row, once before the key is evaluated and once after.
That's true. I put it there because I thought that we should scroll down no matter how the key will be handled (sounds like a universal terminal behavior).
I think it's not bad that the DOM might get updated twice, since this will happen only if the terminal needs to scroll down, meaning that in the next typing there will be no scrolling of the viewport, thus no second (or first 😄 ) DOM update.
Would it be easy to write some unit tests for this? For example:
|
7345418
to
d588ead
Compare
- Scroll to bottom on keydown (when scrolled up) - Add test to ensure above behavior
d588ead
to
0de3d83
Compare
🆗 I moved on with the following:
@Tyriar I don't think I could easily implement tests for Let me know if this is good to go. |
var terminal = new Terminal(); | ||
|
||
// Do not process the keyDown event, to avoid side-effects | ||
terminal.attachCustomKeydownHandler(function () { |
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.
Clever trick 😄
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.
Thanks!
@onttoni just letting you know that we mentioned you for your commit in this PR in the 2.1 announcement. Thank you! |
This PR is a continuation of #326 by @jupe. I kept all original commits, to maintain the appropriate credits 😊 .
This PR introduces this new behavior:
Closes #216.
/cc @Tyriar to take a look since you opened the initial issue and commented also in the original PR.