Scripting Script Debugger

I’m running the script below. It lets the user pick which libraries will be used in a new script. Pretty simple stuff.

There’s an intentional error in the script (when I first tested there was an unintentional error)

In SD6 this works fine, and the error generates a proper error message.

In SD7, first time it ran the script created a new window, and hung before inserting text. (Hung: application not responding, force quit required)

After relaunch, SD7 just hung

After relaunch SD7 created the new window, then inserted the text, then hung (no error message).

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions

set scriptLibrariesFolder to path to library folder from user domain as text
set scriptLibrariesFolder to scriptLibrariesFolder & "Script Libraries:"
set myScriptLibraries to my GetFileNames(scriptLibrariesFolder, "scptd")

set listTitle to "Script Libraries"
set listPrompt to "Which script library(s) would you like to use in this new script?"
set okbuttonName to "This One (these)"
set multipleSelections to true
set emptySelectionAllowed to false

set userChoice to choose from list myScriptLibraries ¬
	with title listTitle ¬
	with prompt listPrompt ¬
	OK button name okbuttonName ¬
	multiple selections allowed multipleSelections ¬
	empty selection allowed emptySelectionAllowed
if userChoice is false then return
set scriptList to {"use AppleScript version \"2.4\"", ¬
	"use scripting additions", ¬
	"use script \"Myriad Tables Lib\""}
repeat with thisScript in userChoice
	set the end of scriptList to "use script \"" & thisScript & "\"" as text
end repeat
set AppleScript's text item delimiters to {return}
tell application "Script Debugger"
	set myNewScript to make new document at beginning
	tell myNewScript to set source text to scriptList & {return} as text
	tell myNewScript to Foo
end tell

return scriptList as text
on GetFileNames(folderWithFiles, fileExtension)
	set folderWithFiles to POSIX path of (folderWithFiles)
	set thePaths to current application's NSFileManager's defaultManager()'s contentsOfDirectoryAtPath:folderWithFiles |error|:(missing value)
	set fileNames to (thePaths's pathsMatchingExtensions:{fileExtension}) as list
	return fileNames
end GetFileNames

I get:

The operation couldn’t be completed. /Users/shane/Library/Application Support/Script Debugger 7/Scripts/Get libs Ed Stockly.scpt: execution error: The variable Foo is not defined. (-2753).

But there is an issue where the error dialog doesn’t always come to the front. I’m just not sure what can be done about it, because it’s not Script Debugger running the script or displaying the dialog.

Ran this script on my system at home with no problem–>Script Debugger 6.0.7 (6A217) on Mac OS 10.11.6 (15G17023)

FYI, how scripts are run is unchanged from SD6.