Skip to content
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

Add support of very big files #465

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

basix86
Copy link

@basix86 basix86 commented Nov 11, 2022

This pull request aims to add the possibility of reading a huge file (e.g. log files)

Usually when a file is opened all contents are copied into memory. This approach can be memory-consuming with very big files.

Example of warning of RText:
rtextBigFile

To solve the problem I have used a paging approach.
I suppose that, in a text editor, there are many sequential reads, always in the same zone of the file.
I copy in memory only a part of the file (e.g. 1 MB) and relative offset.

When we need to access another zone of the file (e.g user scrolls down in the file, we change the offset, and we reload the new part of the file).

The offset is not easier to manage. For that region, I choose to open the file in read-only mode.
The same approach used in IntelliJ:
intellijBigFile

@bobbylight
Copy link
Owner

Can you update this commit to not include all of the whitespace changes? It will make the PR easier to review and avoid unnecessary changes to git history.

@basix86
Copy link
Author

basix86 commented Nov 13, 2022

Sure, I miss disable the automatic format before pushing.
Do you use IntelliJ Idea? Do you have a custom code-style configuration?

REVIEW NOTE:
I have implemented a new document called ReadOnlyDocument. It extends the RSyntaxDocument. I don't like the idea to extend another class but in that case, it could be the easiest solution to modify less code as possible. In the future could be an idea to create and implement RSyntaxDocumentInterface.
I'm not sure if the ReadOnlyDocument name is the best name for the class. Any suggestion? LazyDocument?

Big changes are in TextEditorPane in order to manage two different document types.
I have added a public method loadDocument(FileLocation, RSyntaxDocument, Charset) in order to create ed initialize the outside editor of the new document (e.g in a separate thread with a progress bar, try ReadOnlyDocumentLauncher with a file of 50MB).

@basix86
Copy link
Author

basix86 commented Nov 28, 2022

Hi, @bobbylight do you have any feedback? I know that changes have some impact on the editor's architecture. With these modification, we should add support for two types of documents. Thanks

@bobbylight
Copy link
Owner

Hi @basix86 ! I'm tying to wrap up a minor release with mostly keyboard issues before going on holiday for EOY. I'll dig into this and other meatier stuff after that release.

@basix86
Copy link
Author

basix86 commented Mar 1, 2023

@bobbylight have you planned the release date?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants