-
Notifications
You must be signed in to change notification settings - Fork 13
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
Indenting can be slow #39
Comments
As a point of comparison, reindenting the whole buffer with |
@dgutov Indeed - in the current version of js3-mode, 'reindenting the whole buffer' is simply not an operation to try; but indenting just doesn't work perfectly without parsing the ast. The fix might actually be to re-implement the ast parser from scratch with lisp in mind, instead of trying to use a port of Rhino. Some of the parsing might even be simplified by abstracting it out, since a lot of the subtler distinctions in the language can probably be dealt with as though they were not special cases since it's not going to be executed. If I don't do that soon, I might just bring back some of the old regex-based code for a 'fast but not as good' config option. |
I'm not working fast on this bug since it doesn't actually affect my work; I tend to have js files that are very short, and then compile them later if necessary, which I heartily recommend. |
Do you have an example in mind? So far it doesn't sound like you'd need to do a full rewrite. Rhino or no Rhino, to do 'reindent the buffer' and use the AST you'll probably need an incremental parser. Semantic has one, and they also have a JavaScript grammar for it, so you might want to look into that. |
This issue will be solved in the next (first!) major version of js3-mode, which will likely have another name. Expect it to have a completely rewritten parser. |
It would be nice to allow an option to indent 'by hand'. This means that when you press the tab button, you get 4 spaces (or 2 spaces or 1 tabulation character or 2 tabulation characters or whatever the user customises). I know that a lot of people loves automatic indentation, but when it's slow, buggy, hard to customise, full of special cases, etc., I would like to have the choice to just indent by hand. Thanks! |
@sanbor the latest has the option js3-manual-indentation which I think does what you were looking for. |
@thomblake Amazing, thank you very much, I'm starting to use it 👍 |
For JS files in excess of 100k characters, indenting a line can take a few seconds.
The interim solution is to keep your js files shorter than about 5k lines each.
The text was updated successfully, but these errors were encountered: