php-mode icon indicating copy to clipboard operation
php-mode copied to clipboard

Slow editing inside large string

Open mallt opened this issue 7 years ago • 5 comments

In this example I made a string of 1000 lines This is a $test, and then typing on line 1000 becomes very slow:

php-mode-slow-edit-of-large-string

The cpu profiler shows 65% goes to font-lock-fontify-region: image

Does anybody know if there is a way to speed up the font locking?

Thanks a lot!

mallt avatar Oct 12 '18 12:10 mallt

@zonuexe Do you perhaps have an idea how to speed up the font locking in this case? Thanks!

mallt avatar Oct 26 '18 14:10 mallt

@mallt On my PC 1000 lines is worked fine, but certainly over 2000 lines it was very slow.

I confirmed that javascript-mode does not have this problem. I can not immediately begin this problem, but I'd like to resolve it.

zonuexe avatar Oct 29 '18 17:10 zonuexe

Ok great, thanks a lot for checking this @zonuexe!

mallt avatar Oct 29 '18 20:10 mallt

I've been looking into this problem, and it seems setting c-opt-cpp-prefix to nil instead of \\s-*<\\? on this line seems to mitigate the slowdown when editing large strings. This breaks the indentation after the <?php tag however, so it's not a suitable fix.

@zonuexe Do you have any ideas of how to change this variable without causing indentation to break?

Thanks!

mallt avatar May 31 '19 18:05 mallt

@mallt Certainly it seems to be a great solution. I will consider this.

zonuexe avatar Jun 03 '19 14:06 zonuexe