Besides fixing the folds in the main Lara file, I also made a small tweak to reparse the folds whenever the document changes. I am a bit concerned this might result in a performance penalty for large documents because parsing the folds iterates over each line and every single token. Repeating that on each keystroke could be bad... I thought of a few alternatives:
Parse the folds on file save event. Should be good enough
Implement a timing mechanism where the update only happens when the text is not edited for some N milliseconds. This is a common approach for example in searching forms in web applications that perform API requests. Triggering a request per keystroke impacts performance due to re-rendering, but could also impact the server-side with a flood of requests. So only when the user stops typing for a small interval, the request is triggered.
Although the second option seems more elegant, maybe would be slightly more complicated (not much experience with events and timers in Java..). Is it really worth it?!
Closes #3
Besides fixing the folds in the main Lara file, I also made a small tweak to reparse the folds whenever the document changes. I am a bit concerned this might result in a performance penalty for large documents because parsing the folds iterates over each line and every single token. Repeating that on each keystroke could be bad... I thought of a few alternatives:
Although the second option seems more elegant, maybe would be slightly more complicated (not much experience with events and timers in Java..). Is it really worth it?!