selection updates keep horizontal scrollbars

Hello everyone,
at first thank you marijn for creating codemirror6. It is great!

I have a question regarding content updates:

Situation
One line is longer than the viewport which leads to horizontal scroll bars.
Now I select this line and replace the selection with content that fits in the viewport.

At the moment it replaces the text, but the horizontal scrollbars still exist.

I would assume that the content gets recalculated and the horizontal scrollbars are removed.
Is this behaviour intentional?

Here is an example where the behaviour can be tested via the “Update Selection” button:


Would it also be possible to wrap lines and prevent horizontal scrollbars at all? Are there any examples / ideas how to do this in cm6?

This doesn’t reproduce with recent versions of @codemirror/view for me.

@marijn thank you for the quick response!

I updated the codesandbox example with the latest codemirror versions.
And I confirm that just clicking on the button, it works correctly.

Unfortunately when the editor is focused (so there is a cursor visible), the problem still appears.
Ich created a little GIF that shows what I do and the problem that appears:

Screen Recording 2021-12-06 at 18.51.15

Are you able to reproduce this behaviour?

Ah, right, now I can see it. Looks like some change to the default CSS made the old approach to figuring out which line is the longest break. This patch should help.

1 Like

Thank you for the fix!

I just tested the @codemirror/view main branch with my codebase and it fixes the bug.

I’m looking forward to the next @codemirror/view release.

I’ve tagged 0.19.28

1 Like