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
Fix scrolling on editor interactions when active cell is out of view in windowed mode #16006
Fix scrolling on editor interactions when active cell is out of view in windowed mode #16006
Conversation
Thanks for making a pull request to jupyterlab! |
packages/cells/src/widget.ts
Outdated
/** | ||
* Signal emitted when cell editor requests scrolling. | ||
*/ | ||
get editorScrollRequested(): ISignal<Cell, Cell.IEditorScrollRequest> { |
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.
Based on the investigation in #16007 (comment) it appears likely that a similar signal will be needed for stdin box to fix a related issue with cell not being scrolled to when user types into the stdin box. Maybe it is better to rename this signal to a generic scrollRequested
?
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.
Change made in 438e829
as this will be needed for handling of scrolling to the output area as well.
Thanks @krassowski for making this PR. I probably missed some use case, but I wonder if we need such complexity. It seems to work with:
Again I may have missed some use case where it wouldn't work as expected. |
No, it will not work. CodeMirror will attempt to scroll the container in which it is embedded (see the code of
So the thing I think you are missing is the fact that a cell may be longer than the viewport. In that case after we scrolled to a cell, we may have scrolled to a beginning of a cell. But if the user's cursor was at the end of the cell, the user will be confused. Similarly, if the cell is longer than the height of the viewport but user types in the output (e.g. after running On some level, passing the exact location within cell to avoid scrolling twice would be ideal, but is not achievable with CodeMirror API as of today, and would be way more complex on the level of calculating the appropriate scroll delta.
I do not understand this point. |
Here are two screen recording showing when the logic for
|
Thanks for the clarification and records, this was indeed the case I was missing. |
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.
Looks good to me, thanks @krassowski
References
Fixes #15594
Code changes
EditorView.scrollHandler
:scrollRequested
logic (see below)Cell
is out of viewport (in windowed mode) and the editor requests scrolling it does not attempt to scroll as this is futile (the editor does not know by how much to scroll the virtualized container); instead it emits a newscrollRequested
signal,scrollRequested
signal, scrolls the cell into the view and then scrolls the editor as requested.User-facing changes
Interacting with out-of view cells in windowed mode is more predictable and reflects the interaction model seen in non-windowed mode.
Backwards-incompatible changes
None