tdauth / vjasside

IDE for the scripting languages JASS and vJass of the computer game Warcraft III.
0 stars 0 forks source link

Improve performance of text highlighting #6

Closed tdauth closed 2 years ago

tdauth commented 2 years ago

https://stackoverflow.com/questions/70815376/slow-formatting-in-qtextedit

tdauth commented 2 years ago

Scanner needs improvement:

tdauth commented 2 years ago

Especially common.j needs long. It does not have string literals or function bodies with identifiers. Maybe we have to prestore stuff??

tdauth commented 2 years ago

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.

tdauth commented 2 years ago

Maybe it is painted directly triggering some event? I could try to disable this. Maybe the moving through the document is wrong.

tdauth commented 2 years ago

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!

tdauth commented 2 years ago

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.

tdauth commented 2 years ago

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.

tdauth commented 2 years ago
tdauth commented 2 years ago

Use QPlainTextEdit and block signals. See https://stackoverflow.com/questions/70815376/slow-formatting-in-qtextedit?noredirect=1#comment125216720_70815376

tdauth commented 2 years ago

https://stackoverflow.com/questions/17466046/qtextedit-vs-qplaintextedit

tdauth commented 2 years ago

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.

tdauth commented 2 years ago

Ending highlighting code elements with elements size: 21456 and elapsed time 31435 ms and in seconds 31 and in minutes 0

tdauth commented 2 years ago

QSyntaxHighlighter helped.