-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lazily Load Files #1438
Lazily Load Files #1438
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work as always!
I am approving but I wonder if we should rename CEWorkspaceFile
because it can either represent a file or folder. Naming it file may be confusing to some people.
Description
This PR reworks CodeEdit's file loading system. Specifically:
CEWorkspaceFile.children
attribute.CEWorkspaceFileManager
.In more detail:
Reworks the workspace file manager to lazily load and watch directories.
CEWorkspaceFileManager
no longer loads all files recursively when initialized via theloadFiles
method. In fact, that method has been removed completely. Now, all files are loaded only when needed. See the class documentation for more info on usage and implementation. This has the effect of making CodeEdit usable from large directories (such as a build directory or a user's home directory).Removes the
CEWorkspaceFile.children
attribute.Because the workspace file manager manages loading files, this class could no longer maintain a list of children without heavy dependency on a file manager. Instead of dealing with messy dependency, this attribute was removed. It has been replaced by
CEWorkspaceFileManager.childrenOfFile(_:)
andCEWorkspaceFileManager.getFile(_:createIfNotFound:)
. The combination of these two methods allow clients to fetch cached children and optionally load files from disk.Once files have been loaded into the file manager's cache, they will immediately begin causing file system update notifications. Before that, all notifications for unloaded directories are ignored.
Moves all file modification, and loading code to
CEWorkspaceFileManager
.The methods for modifying, moving, copying, renaming, duplicating, etc. have been moved out of
CEWorkspaceFile
and intoCEWorkspaceFileManager
.Misc fixes:
ProjectNavigatorViewController.copyFile
actually copies the file instead of just duplicating it.Related Issues
TL;DR @EstebanBorai found that loading projects with large directories that were not visible in the editor caused CodeEdit to hang. Lazily loading files was decided on as the best option to fix this issue.
Checklist
Screenshots
No UI changes
Performance