Lost work on a long script

I was working on a long script and was interupted and I left it without saving. When I returned to drafts I was presented a new blank draft and when I went to edit the script reverted to the old version.
Two questions

  1. I know about focus mode - would it have preserved my work?
  2. Could an unsaved script be saved by default if the environment refers to a new draft?

Correct me if I’m wrong, but it sounds like you were editing your script in the script editor inside the action not in a draft. In that case, focus mode wouldn’t have helped, I’m afraid. If you don’t specifically save an action and leave Drafts, it tends to vanish without trace.

I’d say with a long script you’d be better off editing it in a draft and then pasting it into your action.
I’m not really sure what Drafts should actually do in this case. Saving the action automatically would cause major chaos. Maybe something like how Mail handles unfinished emails?

I’ve been burned this way a couple times before as well. Something should be done - just auto save in the script editor might be enough.

Yes that’s exactly what I was doing. I will take your advice and script in a draft in future. It would be good if the draft editor could be used as the default for scripts I think.

In case @agiletortoise is interested in statistics about this:

I have also been bitten by this. More than once…

(While there’s this saying that your code is better when you write it the second time I’m not sure that is true here;)