Why does AppleScript open TextEdit before a list item is chosen?
I'm trying to create a substitute for a Templates folder (like Gnome) via an Automator service, but for some reason TextEdit app opens regardless. I've also tried tell TextEdit open file, but same thing happens.
on run {input, parameters}
choose from list {"TXT", "PYTHON", "ZSH", "HTML"} with prompt "Choose a template" without multiple selections allowed and empty selection allowed
set res to result as string
if res = "TXT" then
tell application "TextEdit"
activate
end tell
else if res = "ZSH" then
tell application "Visual Studio Code"
open file ":Users:me:templates:script.sh"
end tell
else if res = "PYTHON" then
tell application "Visual Studio Code"
open file "Users:me:templates:starter.py"
end tell
else if res = "HTML" then
tell application "Visual Studio Code"
open file ":Users:me:templates:index.html"
end tell
end if
end run