Jump to content

Curly Braces Indentation


Impresario Beaumont
 Share

You are about to reply to a thread that has been inactive for 255 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

As I write a script, the ending curly brace normally positions itself correctly, as in:

if (a == b)
{
     some code
}

at some unpredictable point, however, it stops doing that, leaving the curly brace, as in

if (a == b)
{
     some code
     }

and I have to manually move it back. Is this a bug or am I doing something to cause this behaviour?

Link to comment
Share on other sites

The viewer script editor is prone to losing track of the indentation level for some reason I've never pinpointed, so it's certainly a bug but hard to reproduce on demand.

Erasing the leading spaces on a wrongly-indented line should drop it to the previous indentation level directly, so it's mostly a mild nuisance. You can also use tab/shift+tab with a block of text selected to change the entire selection's indentation level. 

Link to comment
Share on other sites

Yeah, that has annoyed me for sixteen years now.  I have become accustomed to tabbing manually when I am using the editor in the viewer.  When I use Sublime Text, of course, it's not an issue.  I know there are people who don't get worried about such things since the compiler doesn't care, but indentation helps me keep track of scopes in a script.  Besides, a script should be attractive too.

  • Like 1
Link to comment
Share on other sites

There's a reasonably good list in the LSL wiki at https://wiki.secondlife.com/wiki/LSL_Alternate_Editors , and if you search through the archives of this forum you'll see that someone asks about editors about once every six months or so.  There's no shortage of favorites.  I happen to like Sublime Text, although I am just as likely to do my scripting live inworld with the editor in the viewer.  The ones that most scripters use are kept up to date pretty regularly as LL adds new functions, so which one you choose is really a matter of personal preference.

  • Like 2
Link to comment
Share on other sites

The other way I've seen LSL editor indentation glitch out is that sometimes when I try to indent with the tab key, it will paste a portion of the clipboard... or something else, I'm not entirely sure. Been meaning to try and nail down what is actually happening for a proper bug report.

Link to comment
Share on other sites

1 minute ago, Fenix Eldritch said:

The other way I've seen LSL editor indentation glitch out is that sometimes when I try to indent with the tab key, it will paste a portion of the clipboard... or something else, I'm not entirely sure.

Yeah, that one has been with us for ages too. It's annoying but fortunately not frequent enough to be more than a nuisance. 

Link to comment
Share on other sites

49 minutes ago, Fenix Eldritch said:

it will paste a portion of the clipboard... or something else, I'm not entirely sure.

That happens when a tooltip is visible. for example, if you type 'listen' and then hover the mouse over it, then tab will paste:

listen(integer Channel, string Name, key ID, string Text)

it's mildly annoying that it duplicates some of the text ("listen" gets pasted even though you just typed it) and yes, very easy to do accidentally, but it's also useful in limited circumstances.

  • Thanks 4
Link to comment
Share on other sites

4 hours ago, Quistess Alpha said:

That happens when a tooltip is visible. for example, if you type 'listen' and then hover the mouse over it, then tab will paste:

listen(integer Channel, string Name, key ID, string Text)

it's mildly annoying that it duplicates some of the text ("listen" gets pasted even though you just typed it) and yes, very easy to do accidentally, but it's also useful in limited circumstances.

Actually, that's pretty cool and I never knew it did that. I'd quibble about its symbol capitalization, but it's more useful than not.

I don't think that's the bug at hand, though. Instead I see it occasionally insert something like "Comment: blah blah blah" at the cursor location when I hit the tab key. A Ctrl-Z undoes the damage and another tab does what I intended in the first place. (Or maybe that's another different bug.)

 

Link to comment
Share on other sites

30 minutes ago, Qie Niangao said:

I don't think that's the bug at hand, though. Instead I see it occasionally insert something like "Comment: blah blah blah" at the cursor location when I hit the tab key.

Same "helpful" feature: If your pointer is hovering over a comment (and the tooltip is displayed) . . .

/* move text-cursor to next line while mouse-hovering over this line, then press tab: */
Comment (multi-line)
// move cursor to next line while tooltip on this line is visible, then tab:
Comment (single-line)
"Move cursor to next line while hovering over this etc. etc.:"
String literal

listen
listen(integer Channel, string Name, key ID, string Text)

llListen
integer llListen(integer Channel, string SpeakersName, key SpeakersID, string Text);

 

Edited by Quistess Alpha
  • Thanks 2
Link to comment
Share on other sites

4 hours ago, Quistess Alpha said:

That happens when a tooltip is visible.

Oh... OH! I see what's happening now:  that appears to trigger when any tooltip is up. What gets injected at the cursor appears to be the first line(?) of whatever is in the tooltip.

So if for example, my mouse is hovering over a string and I press tab, I'll get "String literal" inserted at the cursor. Just ran through a quick list of various things and it seems pretty consistent now.

default     Type: , Value: 
state       state <target>
state_entry state_entry()
integer     32 bit integer value.
float       32 bit floating point value.
vector      A vector is a data type that contains a set of three float values.
rotation    The rotation type is one of several ways to represent an orientation in 3D.
quaternion  The quaternion type is a left over from way back when LSL was created. It was later renamed to <rotation> to make it more user friendly, but it appears someone forgot to remove it ;-) 
list        A collection of other data types.
key         A 128 bit unique identifier (UUID).
string      Text data.
"string"    String literal
//          Comment (single-line)
/* */       Comment (multi-line)
if          if / else block
else        if / else block
while       while loop
do          do / while loop
for         for loop
return      Leave current event or function.
jump        jump statement
ZERO_VECTOR Type: vector, Value: <0.0, 0.0, 0.0>

So I guess the moral of the story is to watch where you park your mouse when pressing tab while writing code in the viewer. If a tooltip is rendering, you'll scoop up some of its text.

On the fence as to whether I should write up a bug report... as it kinda doesn't seem intentional in my opinion....

Edited by Fenix Eldritch
  • Like 3
Link to comment
Share on other sites

15 minutes ago, Fenix Eldritch said:

that appears to trigger when any tooltip is up.

. . . Yes, even if that tooltip isn't part of the scripting interface. hovering over an object named "Object" with world->hover tips->"show hover tips"(ctrl-shift-t) enabled can paste "Object" into the script window, if the script window is active. (if you click outside the script window, the text-cursor disappears and tab does not paste text.)

Buttons on the bottom row, and some things at the top of the viewer also produce hover-texts with paste-able content.

As a helpful point to a potential bug report, pressing tab in a notecard editing window does not paste hover-tip text.

Edited by Quistess Alpha
  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...
On 8/19/2023 at 7:27 AM, KT Kingsley said:

For what it's worth, the braces issue has been fixed in the latest Friestorm.

Wait.... first we get the option to remove alphas from image uploads that don't need them, and now we get a fix for brace indention? Someone is actually fixing stuff from "r/MildyInfuriating"?

Edited by Phate Shepherd
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 255 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...