The unusual scrolls on Android Webview

From the docs and other resources, I learned how CodeMirror works, and it felt like a pretty good choice for migrating my old project from Ace.

I did some research and really liked CodeMirror 6’s modular design, especially the Lezer parser system, so I migrated my project from Ace to CodeMirror 6. During testing, we found a strange issue: when placing the cursor on a blank line, the cursor should normally stay there, but instead the editor scrolls unexpectedly. This becomes annoying for users.

I checked GitHub issues and found a related issue where the cause seemed to be an Android Chromium/WebView bug. But now I’m not sure what the best solution is. I tried a few workarounds, but none of them worked well. I think this kind of known platform-specific issue should probably be mentioned in the docs, along with possible workarounds or at least some guidance about the known limitations.

One thing I noticed is that the issue is reproducible in the CodeMirror homepage example, but not in the “Try” editor/example. Could this be caused by some CSS or layout difference between the two examples?

Here is a video clip: https://github.com/user-attachments/assets/b9f44ca9-e5d5-4d29-bfce-6da670efbb42

Edit: Btw I found one workaround by setting edit context to false :

EditorView.EDIT_CONTEXT = false

Idk about the side-effects of this but at least the unusual scrolls doesn’t happens now.

Thanks for figuring out this was EditContext related (though I guess I could have guessed). This patch stops giving the edit context the editor’s dimensions, which seems to avoid this behavior.

1 Like

Yeah, now it’s fine even with editcontext.

Thanks for the fix!