dparkins / language-fortran

Syntax highlighting for FORTRAN for atom
MIT License
35 stars 16 forks source link

Slowness / freeze when opening large program #24

Closed Gimly closed 9 years ago

Gimly commented 9 years ago

I'm trying to open an arguably large source code (~5000 lines of code) and the syntax highlighting makes Atom slower and slower until freezing completely the more I scroll down in the file.

I've tried disabling the syntax highlighting to make sure it was indeed the issue, and it works perfectly fine without syntax highlighting.

If you want to try with the same file, you can download this archive http://s-provencher.com/pub/contin/contin.for.gz that contains the .for file that I was working on.

tomedunn commented 9 years ago

Hey @Gimly, I checked the code you linked and this bug is due to the current grammar rules being inconsistent with older Fortran standards regarding DO-loops as outlined in issue #23. In essence, the syntax rules try to apply scopes to things like functions and subroutines as well as do loops. Currently the only way to end a do loop is with the end do statement (continue leaves the scope open). So by the time you get down to line 2000 in your code you have around 30 nested do-loop scopes which is causing the slow performance.

I've been working on a fix for this and while I don't have a good general fix yet, I can upload a quick fix tonight that adds continue to the rules for closing do loops. This should at least make your file workable for the time being.