Script Editor syntax highlight color issues in SLV 26.4
AlettaMondragon Resident
Viewer: Second Life Release 26.4.0.37384746592 (64bit)
Issue:
Apparently the script compiler mode selector confuses the syntax highlight colors and the line ID across different scripts because it defaults to Lua even if the script was written and compiled on LSL or LSL on Mono. As a result, the syntax highlight colors in LSL scripts go missing, and making them work seems to be very inconsistent (there might be a pattern but I haven't recognized it yet).
What I observed:
1: When you launch SLV 26.4.0 for the first time, or now also Firestorm 7.3.0.82931 (Beta), any LSL script you open will show either in default text color only, or only comments and strings will be highlighted, or the editor will fail to highlight comments and it will highlight random words from comments that match event or constant names. Typically, functions and data types will not be highlighted.
2: The ID of the first line will be 1 instead of 0, which is another indicator that the editor defaults to Lua and doesn't recognize the LSL script.
3: When this happens on the first launch of the viewer, you might or might not be able to fix the highlight colors by recompiling and saving the script, and then closing and opening it again. Launching the viewer the second time and so on, you can fix the highlights in each script by recompiling and saving it.
4: If you change the compiler to Lua, save the script, close it, then open it again, switch to any of the other modes and save it in that, it might break the highlights completely and they cannot be brought back by recompiling or closing and opening, but then they will show correctly after a relog. The "New Script" in my attached pictures is one I created last night on FS 7.3.0, today I played with it at https://maps.secondlife.com/secondlife/Lua%20Beta%20Void/216/24/23 to test the different compiler modes. As you can see, events, the default state, the integer data type and functions are not highlighted, only strings are, and in the script colors window only strings and comments are highlighted, nothing else. In the last picture you can see the same happening to an older script. I had to close the viewer and launch it again to bring back the correct highlight colors.
5: The length of the script and whether it starts with // or /* comments seem to affect this issue as well. Opening short scripts might produce this failure less often than opening long scripts (1000+ lines), and comments in the first line seem to be a contributing factor as well, but it is not a solid way to reproduce this issue. It seems to point toward the problem that the editor defaults to Lua syntax now and fails to recognize LSL scripts.
6: If you copy-paste lines in a script that is showing the highlight colors correctly, the new line will be in default text color for a moment (less than a second) before the highlight colors render. The highlight colors used to render immediately, without this flash, so there might be something in the compiler that takes some time to render the highlights. It might be the same issue that it has to recognize the syntax first.
The above are not reproduction steps, only observations. Sadly I don't have solid reproduction steps for any of this, but needless to say it is very annoying to have to recompile each script to see the highlights, and the flash from the text color to highlights in newly pasted lines is very uncomfortable to look at as well.
Photo Viewer
View photos in a modal
Log In
Tapple Gao
viewer 26.4 is several months old. can you reproduce in viewer 26.5?
EDIT: nevermind. I tried on viewer 26.5 and saw the bug after I opened and closed a few scripts. I was not able to reliably reproduce it from a relog. I have crappy internet. I wonder if it's related to taking too long to download the script asset
Second Life Release 26.4.0.33894281402 (64bit)
Tapple Gao
here's the logs from the session where I saw the issue: https://cdn.discordapp.com/attachments/1348710493656977488/1573341034996305981/SecondLife.old?ex=6b01a786&is=6b005606&hm=f9c454a74ea50f5526e32836635e1c860d56aa4ae1daf4f95663d027fe405dd6&
AlettaMondragon Resident
Tapple Gao I didn't have enough time to figure out how exactly it happens, but I think I only managed to break certain scripts permanently in Lua regions. That is because a Lua script seems to create a different asset (it gets a different inventory icon), so when I made a new Lua script and then compiled and saved an LSL script in it, it broke, and if I compiled an existing LSL script in Lua (it failed of course) and saved it, the highlight broke in that too.
So it seems out of all my weird observations, these 3 are consistent:
1: Creating a new script in a Lua-enabled region and then changing it to LSL breaks the syntax highlight permanently in that script file and saving an originally LSL script in Lua will do the same. (Still not confirmed.)
2: The syntax highlight lags behind when you start or copy-paste new lines. Explanation of this is below, that this was necessary for the Lua parser but now it affects the LSL compilers too. I will file a feature request for the LSL compiler to work as it used to, because it seems unreasonable to have this effect on it that is not necessary at all (it is only necessary for Lua as it seems).
3: When you open a script that hasn't been saved in the new script editor yet, you will have to recompile and save it if the syntax highlight is missing or incorrect when you open it. This is confirmed, but the details like when it happens, are not. To me it looks like the parser is confused in some cases when the script starts with many // comment lines, especially if the script is very long.

Dan Linden
The delay in highlighting is from https://github.com/secondlife/viewer/issues/5278 and was necessary to keep viewer performance high.
AlettaMondragon Resident
Dan Linden Thank you Dan, so what I noticed is this as explained by marchcat "The Lua parser is much slower than the LSL parser, so before this fix, you had to wait for the entire highlighting process to finish before seeing the character you typed (sometimes up to 2–3 seconds). With this fix, you see what you type immediately (in black), and then it gets highlighted when ready."
However since syntax highlighting was moved to a separate thread including the LSL modes as it seems, this means this behavior happens in the LSL modes unnecessarily, since this would only be needed for Lua? Is it technically possible to separate them so that the LSL modes' syntax highlighting could stay the same it used to be, and this change only affect Lua? Or is it getting out of development scope anyway because we should rather work in Lua only, once it will be fully supported everywhere on the grid?

Dan Linden
Hi AlettaMondragon.
I have not been able to reproduce this issue. Can you get a video of this bug happening? I'd like to see all the steps from opening the script until the issue reproduces.
AlettaMondragon Resident
Dan Linden Here is the video of one aspect of this issue: https://screenrec.com/share/nUa5LEfpO8
This is one script in which the syntax highlighting went completely broken somehow. As you can see changing anything in the script or changing compiler modes doesn't bring back the highlights, closing and opening it again doesn't change anything either, even copying the script or pasting it into a new script file doesn't change the broken highlights. And only comments and strings would get highlighted in this one.
I can reproduce this with a new script too in the Lua Beta Void region. If I make a new script there, it will be a Lua script by default. It will only show highlights on strings. Then if I change it to LSL or LSL on Mono, and I replace the default Lua script with LSL, it still won't show any other highlight, only strings and comments. That one is in this video: https://screenrec.com/share/Xj7IBV4UGP
These seem to be consistent on my end. If I manage to reproduce more aspects consistently, I'll try to capture them too.

Dan Linden
AlettaMondragon Resident: Right, ideally I'm looking for a video that starts while highlighting is working correctly, and then breaks, so we can inspect what might have caused the breakage.
I'm still not able to reproduce the issue here.

Dan Linden
Next time this bug reproduces, please send us the SecondLife.log immediately after that session. It
may
hold a clue.This page tells you where to find the logs folder: https://community.secondlife.com/knowledgebase/english/how-to-report-a-bug-r224/
Email the file to bug-attachments@lindenlab.com and reference the issue name in the email subject line.
AlettaMondragon Resident
Dan Linden Thank you, I will try to capture how the highlight breaks when I figure out the steps. So far the only failures that were consistent on my end are these in the 2 videos. Those also don't seem to repro on any non-Lua region, by the way.