-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
julia-mode.el: hitting return at top level is very slow #9254
Comments
cc @Wilfred |
Ouch, sorry about this. This is the pathological case with our current indent logic. As currently written, our indent logic is O(N) time where N is the line number that the cursor is on. When we indent, we search back through the buffer in order to find the last unclosed block.
This generally gives correct results, but it scales awfully when point is outside a top-level expression. I think the best solution would be to only consider the last non-empty line:
c-mode and ruby-mode seem to do this (js2-mode and python-mode do something smarter, I haven't investigated how). This would be much much faster. It would break on the following case (I can't think of any other corner cases):
However, we don't currently indent this correctly, and I think peeking backwards by one more line would be sufficient to handle this. I'll work on a patch. |
I don't think c-mode does that. For example in julia.h there is an |
This is much faster, fixing JuliaLang#9254. WIP.
This is much faster, fixing JuliaLang#9254.
This is much faster, fixing JuliaLang#9254.
Aha, you're right. This was the test I did:
Note that I think considering the previous line is a reasonable approach, though I'm open to other suggestions. You can see the code on my branch -- I've also written a set of unit tests. Before sending a pull request, I also want to offer a Python/Haskell style indent toggle. This will give users flexibility and be considerably less annoying if the user hits a bug. |
Fixes JuliaLang#9254 -- performance is just too bad on long files otherwise.
Fixes JuliaLang/julia#9254 -- performance is just too bad on long files otherwise.
There is a significant delay when hitting the return key with the cursor at the top level of a file (outside any function or block). The farther in to the file you are, the longer the delay. For example put the cursor at the very end of
test/core.jl
and hit return. For me there is a full 3 second delay, which is unbearable.This seems to have been introduced fairly recently.
The text was updated successfully, but these errors were encountered: