Version: 2.0.85 (using KDE 4.4.2) OS: Linux Syntax highlighting when editing a long (~5000 lines) document is slow. Whenever I input a dollar sign, or a "\section{", or anything requiring a re-parsing, in the first part of the document, then the editor hangs for a noticeable time. I suspect this is due to a full re-parsing of the document each time. It would make the interface snappier to perform one only after n seconds, or to parse only the visible part of the screen. Reproducible: Always Steps to Reproduce: 1) open a long (~5000 lines) latex document - I can send you the draft of my thesis if you need :) 2) input three or four dollar signs just after the \begin{document} Actual Results: The editor stops responding to user input for a couple of seconds, even on a "modern" computer Expected Results: Syntax highlighting changes almost immediately OS: Linux (i686) release 2.6.32-23-generic Compiler: cc
Forwarding to KatePart. I think a general overhaul of the LaTeX syntax file is also due. If I can find some time in the near future, I will have a look at it.
please provide me with such a long file so I can profile it.
Created attachment 51289 [details] long LaTeX file
I suffer from this problem too. As you requested, I am attaching a long LaTeX file for testing. It is 200 pages UTF-8 encoded math text in Russian (if you are curios, it is my habilitation thesis). When I type several (20-30) dollar signs at the beginning of this file, kate (or kile or kwrite) stalls and my CPU fan goes crazy. Deleting these dollar signs using backspace has the same effect. This is with KDE 4.5.1 from Kubuntu PPA packages. I see three issues to fix here. (1) katepart should not reparse the entire file after a keypress. At least not when the screen is not updated yet or there are keypresses pending. (2) There should be an option to turn the syntax highlighting off. Or, if it is there, a mere mortal should be able to find it. (3) The LaTeX highlighting rules should be improved. What is wrong now is that an unmatched dollar sign (that is, when a user started a formula but have not yet finished it) makes the whole rest of the file highlighted as math. A natural way to fix this is to let an empty line stop the math mode. After all, this is exactly what LaTeX does. If such a rule is implemented, only the current paragraph would be reparsed while a formula is typed in. In KDE3 days I had a private patch doing just this, and it made all these speed problems go away. Now I tried to add a line <RegExpr String="^\s*$" attribute="Error" context="#pop"/> within "MathModeCommon" context in latex.xml, hoping that this would do the trick. Unfortunately it did not work (unless empty lines contain some actual space characters) as katepart does not seem to be able to match an empty string.
Partly fixed in r1176817. If you type and the context remains the same, no reparsing is done. There is no delayed parsing though, and I'm not sure whether it's feasible to implement.
I have fixed the empty line detection in bug 274289, could somebody enhance the latex xml spec?
Created attachment 75944 [details] Add empty lines attribute to MathModeCommon
The patch should implement the empty line recognition. As I don't have a recent KDE it is untested. @Sergei Ivanov: You can turn syntax highlightning off only in the settings menu deep inside kile. I tried a bit and looked for a workaround, but it just seems that math mode detection is too slow. And making it faster is not that straightforward. What you can try is to split the document into multiple files and use \input. Oh and inserting "$ $" instead of "$$" is also much faster.
Thomas, can you test again with a recent KDE version?
For me that works well and fast with KWrite in the Frameworks 5 version.