-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix teleport when exiting out of alt buffer. v2 #5411
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
base: master
Are you sure you want to change the base?
Conversation
src/browser/Viewport.ts
Outdated
// If ydisp has been changed by some other component (input/buffer), then stop animating smooth | ||
// scroll and scroll there immediately. | ||
if (ydisp !== this._latestYDisp) { | ||
this._latestYDisp = 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.
Does it work if we set this only when this._latestYDisp
is undefined? Normally _latestYDisp
is set when handling scroll events, not syncing.
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.
I just tested this with conditional this._latestYDisp is undefined
, and it's not working..
this._latestYDisp
switches from 0 to 1000 in queueSync
, and this this._latestYDisp
passes down and becomes ydisp
in sync
where
if (ydisp !== this._latestYDisp) { // 1. this would be 0 !== 1000
this._scrollableElement.setScrollPosition({
scrollTop: ydisp * this._renderService.dimensions.css.cell.height // 2. ydisp is 0.
});
}
Afterwards, when latestYDisp is 1000, and ydisp is also 1000, we don't get to call
scrollTop: ydisp * this._renderService.dimensions.css.cell.height
because if (ydisp !== this._latestYDisp)
is false, and this would leave the scrollTop to remain 0, instead updating to correct value (end of buffer)
---> Hence you get stuck in 0 scrollTop position.
Also, _sync 's ydisp cannot actually be undefined since it has default value, from:
private _sync(ydisp: number = this._bufferService.buffer.ydisp): void {
Long story short,
In the "teleport" scenario, I think the the problem appears because we don't get to update scrollTop to the correct place when we go from having 0 to 1000 ydisp
when calling _sync
Maybe this is also some race condition, as I can only repro sometime
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.
Does this._bufferService.buffers.onBufferActivate
need to be handled specially? It seems like it's related to buffer switching during a smooth scroll happening. You could try increasing smooth scroll duration significantly (10000ms?) to see if it's easier to repro?
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.
Yeah, maybe more proper/intuitive fix is that we set latestYDisp to undefined onBufferActivate.
This way we prevent from any contamination when switching between buffers.
Setting the smooth scroll to 50000 and also aggressively scrolling and letting the mouse scroll run right before exiting out via q!
seemed to help me repro more consistently.
Had people try out: microsoft/vscode#224750 (comment)
Apparently #5390 wasn't enough.
If you really interact scroll around alt buffer, after maxing out in normal buffer, you can sometimes repro this if you get lucky.
@Tyriar The teleport issue came back, this time it was more difficult to repro, but I was able to repro.
Steps to repro for me was:
echo -l {1..10000}
:q!
I spent some time and it seems like at certain point
undefined !== 1000
causes true forwhen ydisp is undefined after exiting out of alt buffer. Hence scroll will be brought to very top.
xterm.js/src/browser/Viewport.ts
Line 97 in a1d8e96
EDIT: ydisp cannot be undefined in sync due to #5411 (comment)
Adding
this._latestYDisp = ydisp
in_sync
similar toqueueSync
seems to solve the problem.Here are some logs PRE-PR:
(Entering vim)

(Exit out of vim)

(start scrolling)
