"Dangerous" indenting and beautifying behaviour inside the script editor window when a " is missing

vibos shared this problem 1 week ago
Not a Problem

I really like the automatic indenting and beautifying feature of the script editor!!! This automatic indenting is executed by clicking the ok button. But regretfully in a certain situation it can almost destroy a script which consists of several strings: if you forget to put the closing " at the end of a string - or if you simply delete the closing " by mistake, the indenting tears apart ALL following strings.


Let me explain it with the following example. Put it into the general JavaScript area:


function ggbOnInit() {

a = "This is an example.";

b = "This is another example.";

c = "This is the third string.";

d = "And this is the last string.";

e = Array("aaa", "bbb", "ccc", "ddd");

}

Hit the ok button to get it beautified.


Now delete the finishing " at the right end of string a:


function ggbOnInit() {

a = "This is an example.;

b = "This is another example.";

c = "This is the third string.";

d = "And this is the last string.";

e = Array("aaa", "bbb", "ccc", "ddd");

}


Again push the ok button to get it beautified.


The result is this:


function ggbOnInit() {

a = "This is an example.;

b = "

This is another example.

";

c = "

This is the third string.

";

d = "

And this is the last string.

";

e = Array("

aaa ", "

bbb ", "

ccc ", "

ddd ");

}

Of course this is not such a big problem if the script is that short, but I use to write much bigger scripts, and several times I stumbled over torn strings after hitting the ok button until I found the reason for it.


Is there a way to "undo" such a torn script? For the moment my solution is using CTRL-S each time before I hit the OK button. And I'm extremely careful with editing texts in strings.

Comments (1)

photo
1

I suggest you write longer scripts in a dedicated editor like Notepad++

© 2019 International GeoGebra Institute