You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The TextArea widget code queries the entires syntax tree for each edit,
using the tree-sitter Query.captures method. This has potential scaling
issues, but such issues are exacerbated by the fact the Query.captures
method scales very poorly with the number of line it is asked to
generate captures for. It appears to be quadratic or something similar I
think - I strongly suspect a bug in tree-sitter or its python bindings.
On my laptop, this makes editing a 25,000 line Python file painfully
unresponsive. A 25,000 lines Python file is large, but not entirely
unreasonable. I actually became aware of this behaviour developing a
LaTeX editor, which showed symptoms after about 1,000 lines.
This change replaces the plain TextArea._highlights dictionary with a
dictonary-like class that lazily performs item access to build
hilghlight information for small blocks of (50) lines at a time. As well
as keeping the TextArea very much more responsive, it will reduce the
average memory requirements for larger documents.
During regression testing, I discovered that the per-line highlights are
not necessarily in the correct (best) order for syntax highlighting. For
example, highlighting within string expressions can lost. So I added
suitable sorting. This required that the snapshots for some tests to be
updated.
0 commit comments