Closed tdauth closed 2 years ago
Scanner needs improvement:
Especially common.j needs long. It does not have string literals or function bodies with identifiers. Maybe we have to prestore stuff??
Even with string literals and keywords and brackets it takes the same time:
Ending highlighting tokens with tokens size: 46852 and elapsed time 75733 ms and in seconds 75 and in minutes 1
Custom scripts are much faster.
Maybe it is painted directly triggering some event? I could try to disable this. Maybe the moving through the document is wrong.
It might because of the wrong order of tokens/syntax errors. The syntax errors were in the wrong order. They all have to be ordered by their occurance in the document!
Better idea: Just highlight the lines visible in the viewport. This will reduce the highlighting from like 4000 lines to 100 or something. However, it needs constant updating but only once. After that it is stored until the text changes. The highlighting in Kate takes about 2 seconds and it doesn't seem to only highlight the visible area.
Parse Errors are still not ordered by their location. Order them before highlighting. Do the same for tokens. Merge both highlightings together into one list with information for highlighting.
They could use some shared parent type.
Use QPlainTextEdit and block signals. See https://stackoverflow.com/questions/70815376/slow-formatting-in-qtextedit?noredirect=1#comment125216720_70815376
Diffs of highlighting infos:
Go through all lines and all columns:
Only these two possibilities exist.
function test takes unit whichUnit returns nothing
endfunction
is changed to
// comment
function test takes nothing returns nothing
endfunction
generates the following diff:
+ comment (0, 0)
+ keyword (1,19)
Hence, it only applies two highlighting changes.
Generating diffs would also allow to highlight a document step by step, highlighting blocks.
Ending highlighting code elements with elements size: 21456 and elapsed time 31435 ms and in seconds 31 and in minutes 0
QSyntaxHighlighter helped.
https://stackoverflow.com/questions/70815376/slow-formatting-in-qtextedit