Selected text after error is not right

I noticed in SD8 that if I run a script that has an error, when SD stops execution part of the line where the error occurred is selected, and part of the line immediate following is also selected. (if the second line is not empty).

Can you post a screenshot?

FWIW, I’m on SD8 and separately ran the following scripts without encountering the selection-overrun error mentioned by Ed. I wonder if the nature of the original error that causes the selection overrun makes a difference. I tested the scripts with different settings (like word wrap) and that didn’t seem to make a difference.

-- Test Script 1
set aVariable to "aa"
set aVariable to 
set aVariable to "aa"

-- Test Script 2
set aVariable to "aa"
display dialogg "OK"
set aVariable to "aa"

This issue occurred on when I installed and first launched SD8 on Mac OS 11.

It repeated several times.

Since relaunching SD it hasn’t happened.

I’ll see if it comes back after rebooting.

Happened again and it’s reproducible. Here’s a link to movie on OneDrive.
https://caltimes-my.sharepoint.com/:v:/g/personal/ed_stockly_latimes_com/EbSzx3fiDAtMsWs_1bFXt0UBdzbALCj5cAvOcgq9cUPv9w?e=Qxh8et

The scenario for the error is I pasted an application’s script into a new script window and ran it without saving. There’s a handler call to a handler that does the persistent values, but can’t since it hasn’t been saved as an app. The error should be reported in the handler but instead is reported
near the handler call in the run handler. But, as you can see in the movie and screenshot, the selection whacked.
→ Script Debugger 8.0.1 (8A36)
→ Mac OS 11.6 (20G165)

I also noticed a similar error reporting oddity.

I had a handler call that was trying to set the end of an undeclared variable to the value returned of the handler. The error should have highlighted the handler call but instead was inside the handler.

It took me a while to figure out exactly what the error was. I tried to reproduce it but it was difficult. The handler had several AppleScriptObjC commands and that may be related, because when I repeated the scenario with a plane vanilla AppleScript it didn’t happen again. I’ll try to do a minimalist version of the script if that would help.

What do you see if you do it in Script Editor or Script Geek?

In script editor it generates the same error, but does not select any text. The cursor/insertion point is at the beginning of the script.

In Script Geek the script won’t compile. It says a particular variable is not defined.

I checked your video, and the error is happening in a script library you call. When that happens, the range returned by AppleScript is meaningless in terms of the script on your screen.

It’s difficult to know the best way to handle such a case. Script Editor just ignores the range. Because it’s often near the error, Script Debugger will select it anyway (if possible). In an ideal world the lib would be opened and the (hopefully) correct selection made there, but (a) it might be run-only, and (b) tests in the past have shown the range is not correct.

The key, I guess, is to remember that if the offending item is a script library, the range may be wrong.

We’ve logged bugs with Apple on this, but I’m not optimistic.

OK, the issue for me is that it can be hard to figure out where the error is happening.

It’s definitely the weak link in the implementation of script libraries.