markusfisch / ShaderEditor

Android app to create GLSL shaders and use them as live wallpaper
https://play.google.com/store/apps/details?id=de.markusfisch.android.shadereditor
MIT License
924 stars 137 forks source link

Bug: Highlighting synchronization with shown text #192

Open AntonPieper opened 3 months ago

AntonPieper commented 3 months ago

If I remove N characters and add N characters again without changing the token type within the update delay, the highlighting was removed due to how spans work (but does not reappear). This happens, because highlighting does not happen immediately but only after a period of inactivity and the diff algorithm is based on current tokens and last highlighted tokens. A naive/simple fix to this issue is to track the first and last edited character and then always replace that range with the new highlight tokens. Another way of fixing it would be to immediately apply the highlighting as soon as the tokenization finishes.

markusfisch commented 3 months ago

Hm, I somehow can't really reproduce this 🤔

Could you please give an example like removing and adding "oor" from "gl_FragCoord" or something like that?

AntonPieper commented 3 months ago

Of course, I can give an example:

It should be:

But what happens:

This happens at the boundaries of tokens, because they are fixed to words/characters and not rows/columns.

Another extreme example:

(Works best with highest update delay)

Select All -> Copy -> Delete all -> Paste