This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Repository navigation
Load large files in background - #7060
Closed
nathansobo wants to merge 16 commits into
Closed
nathansobo wants to merge 16 commits into
nathansobo wants to merge 16 commits into
Conversation
|
Woo! |
Contributor
There was a problem hiding this comment.
Any reason to not use the <progress> element from the style guide?
Contributor
Author
There was a problem hiding this comment.
Only that I didn't know it existed. Will update.
added 15 commits
June 3, 2015 00:33
Rather than recomputing it for each line. Also, recycle the same openScopes array for each placeholder since they are immutable and all the same.
When passed largeFileMode: true, the TokenizedBuffer spawns a background task to build the initial set of tokenized lines, so that expensive computation related to scanning for leading whitespace, hard tabs, paired characters, etc is performed in the background. This means the TokenizedBuffer won’t be ready to use synchronously after construction, and we’ll need to handle this in the DisplayBuffer, TextEditor, and the view as well.
This object serves as a placeholder pane item for editors that are being loaded asynchronously. It replaces itself with the editor once it loads, and I will add a progress bar shortly.
Still needs to be styled
Signed-off-by: Max Brunsfeld <[email protected]>
Indicate this by change load progress from 1 to 0 again. Signed-off-by: Max Brunsfeld <[email protected]>
Since progress can drop back to 0, this seems more clean and symmetrical than adding `onDidStartReloading` or some similar method. Signed-off-by: Max Brunsfeld <[email protected]>
Contributor
Author
|
Rather than doing work in the background, I've found a way to drop a couple features and just not do the work at all. |
|
Uh, I'm sure more than a few people are having large files that should be highlighted for grammar, maybe consider getting this merged? |
Contributor
Author
|
I'm going to look into background highlighting next week, but that's a different story. We won't support folds and soft wraps for a while though which is the only reason we'd really need to do this. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
🚨 Work In Progress 🚨
Loading a 3.7MB file created by concatenating jQuery to itself multiple times:
Constructing the initial set of
TokenizedLines hangs the UI thread for large files. This PR performs this work in a background task for files above a certain size to avoid the pause, indicating progress with a progress bar. To integrate smoothly with existing packages, we open aTextEditorLoaderitem to display progress until the editor is fully loaded, then replace it with the editor afterward. This ensures that no packages attempt to interact with an editor in a partially loaded state.Remaining Issues
Can't change grammars
We currently use tokenized lines to store horizontal spatial information such as hard tabs, paired unicode characters, soft-wrap indents, etc. This is in addition to their primary purpose of representing syntactic scopes. This entanglement makes it awkward to change the grammar once the file is loaded, because doing so replaces all the tokenized lines with the same placeholder lines we're constructing in the background to clear all the styling, then starts tokenizing again from the beginning. However, this takes a lot of time for a large file. Once the editor is loaded, I don't want to put it back in "background loading" mode because that implies a lot of complexity. Ideally I'd like to store the horizontal spatial information outside of the tokenized lines, so styling could be cleared without throwing away all this computation.
Can't change tab length, invisibles, etc
Again, these require recomputing the tokenized lines from scratch. Invisibles can be dealt with by separating them out into a second rendering phase once our position calculation is more decoupled from the content of the model. Tab lengths are not so easy. We may be able to use our existing metadata about tab locations to update the lengths more efficiently in a synchronous way (without having to scan every token). Or we may want to just disable the ability to change it over a certain size. Or we may need to bite the bullet and figure out how to put the editor back in "background loading" mode after all. I'd like to put that off though.
Long pauses before / after progress bar
The initial pause is due to loading the entire buffer in the background task before beginning processing. I just did this as a first pass implementation and will fix it before merging this. The second pause is autocomplete-plus populating its symbol table. We may want to disable it for now for files above a certain size, then work on optimizing this.
Tasks
I may want to push tokenization to a background task in a different PR. That would allow us to at least select an initial grammar for large files instead of the null grammar as is currently the case on this PR. But I think loading huge files without highlighting is enough of an improvement to do that in a second pass.