Textmate thread safe
spf-oss opened this issue · 3 comments
Calling "grammar.TokenizeLine(line,rulestack)" by two threads at the same time will cause thread safety problems. How do you solve them?
If I want to achieve the effect of vscode, when the code is very long, first of all, one thread of vscode will refresh the code color from the code in the visual area (the color may be wrong at this time), and then another thread will refresh the color from changing the position. At this time, there will be a phenomenon that the syntax starts two threads.
In this way, you can achieve the rapid response of code color and ensure the correctness after refreshing.
What should I do to achieve this effect?
Well this behavior is already implemented in AvaloniaEdit and it's working fine. Take a look.
It parses the viewport in the UI thread and starts parsing the document in a bg thread. Every time the viewport is scrolled, the view port is re-parsed.