Repository navigation
Open long files without freezing the window - #153
Merged
Merged
Conversation
Opening a long file styled it twice, once in setPlainText and again in a typography pass over every block, and drew every line of it into the first frame, since Qt Quick only limits drawing to the viewport for text set through TextEdit.text. A 7 MB file took about 5 seconds of the main thread and 1.4 GB. The text is now inserted under the line height in one edit block, and the editor draws only what is on screen. The same file opens in about a second and 790 MB, most of which is Qt's layout of every line. Fixes #137 Co-Authored-By: AgentRBY <mrget112@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[Medium impact] The follow-up appears safe to merge. SummaryThis PR reduces repeated work when opening long files and limits drawing to the visible text.
No new issues found in the follow-up changes. Reviews (3) · Last reviewed commit: "Check that opening a file changes the do..." · Reviewed by Greptile |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #137.
Opening a long file styled it twice:
setPlainText, thenapplyDocumentTypographychanging every block's format, which the highlighter followed with a second pass over the whole document. And Qt Quick drew every line into the first frame, because it only limits aTextEditto its viewport for text set throughTextEdit.text, never through its document.loadDocumentTextclears the document and inserts the text under the line height in one edit block, with undo off, so the file is styled once and there's one change notification.attachDocumentsetsItemObservesViewporton the editor, so only what is on screen is drawn.On a 7.5 MB, 92k-line FASTA file like the one in the issue, offscreen:
Most of the remaining memory is Qt itself: a bare
QTextDocumentholding that file and laid out at the editor's width takes about 730 MB. Going lower would mean not usingTextEdit.This is the load-path half of #133 by @AgentRBY (credited as co-author), brought onto the CMake build, with the clear moved inside the edit block and the stale comment on
applyDocumentTypographyfixed. #133's popup and QML-compilation changes are left to that PR.🤖 Generated with Claude Code