flutter-code-editor icon indicating copy to clipboard operation
flutter-code-editor copied to clipboard

Large files do not render correctly

Open albe-jj opened this issue 1 year ago • 4 comments

If I open a file with more 1000 lines it does not not display correctly after a certain point it only shows blank lines. Also for these large files widget uses a lot of CPU and RAM.

albe-jj avatar Oct 05 '24 11:10 albe-jj

I saw that the problem of lines is fixed by adding height to the GutterStyle property. The performance is good for me, but the situation worsens when typing.

peter-kal avatar Dec 05 '24 20:12 peter-kal

It seems already discussed in other issues, like #255.

peter-kal avatar Dec 05 '24 20:12 peter-kal

I have started a branch to solve this issue for myself. It currently supports opening any file size, but doesn't support saving edits yet. I ideally want to add a debounced auto save and a manual save at some point.

It currently works by grabbing a chunk (default size 500 lines), and loading new chunks if you're within an overlap (default of 50 lines). It also obviously jumps the line numbers so it's "seamless", but the scroll velocity isn't maintained so it does stop a bit suddenly sometimes. I don't know of any way to maintain that scroll velocity and it doesn't look too bad so I'm happy for now

This repository does look a little dead so I'm aware I might be posting into the void :) https://github.com/ViscousPot/flutter-code-editor/tree/feat/file-editor

ViscousPot avatar Aug 07 '25 06:08 ViscousPot

For the record, I've abandoned that branch as is because I've found, what seems to be, a simple and robust solution using re_editor and mmap2. re_editor because it swaps out the TextField for something more efficient, which allows the rendering of very large amounts of text and mmap2 because it efficiently handles loading and editing very large text files (mostly).

Hope this is useful for anyone trying to do the same :) Please do point out any issues with the approach!

ViscousPot avatar Sep 11 '25 06:09 ViscousPot