Closing, quitting routines

I think I raised this issue before, but I’m bringing it up again because last night when I was trying to leave work SD kept slowing me down and it was frustrating.

There are two issues. First, if you’re working in a window with multiple tabs, and you try to close the window SD switches to the first tab and tries to close that, presenting a save dialog if it’s modified, then either switch to the next tab or cancel closing. What it should do is try to close the current tab, display a save dialog there, then go on to the next tab (unless the user cancels.) Other apps with tabbed windows do that and it’s preferred.

The second issue with with quitting SD. For me it last night it came when I was shutting down and twice I had to cancel the shutdown to deal with SD windows.

It’s nice you’re given the option to review changes, but once you start looking at individual tabs, you’re not given enough flexibility to pick and choose which you want to save and which you want to close. In some cases, I couldn’t see the script it was asking me to save or not save and I had to cancel, which canceled the quit and the shutdown.

During quitting the user should be given more useful options.

For this one, I suggest you use the Close Window (Command-Shift-W or click in the window’s close button) command rather than the Close (Tab) command. This causes SD to present a single Save panel for all documents in the window:

You can select the documents you want to save and the ones you want to abandon using the check boxes in the panel.

If you can be more specific about what “more useful options” would be I’ll file a feature request. If we do a SD7, I’ll probably replace SD’s existing tabbed window implementation with the one provided by Apple in Sierra and that may limit our options.

Yes, that is how I’m closing windows. I believe that screen grab you showed comes up when you are quitting SD (or shutting down) not when you’re closing a window with multiple tabs.

With the interface shown in the image you posted, if you have multiple tabs/windows open but aren’t sure which is the one you want to save and which is the one you don’t need to save, you have limited options. You have to cancel the quit and then close the documents, windows one at a time.

Mark, you might take a look at how BBEdit handles quitting with unsaved files.
I believe there is an option to just quit without any prompts, and BBEdit saves ALL unsaved files in a temp location. It then restores them when you launch the app next time.

I find that very convenient.

I’ll point out that BBEdit has a much simpler task: storing text documents. The requirement that non-text script documents be compiled in order to be saved presents significant challenges. We could, I suppose, fall back to text/rtf but its not possible to restore all state correctly. I spent an enormous amount of time trying to solve this challenge cleanly in the SD4.0 development cycle and settled on the current compromise.

Not just quitting the app. If you click a window’s close button or use the Close Window (Command-Shift-W) command you’ll see this panel.

? - The names of your documents are listed. You can elect to save or abandon each document from the panel. If you want more detail like being able to review the content of the document, then close the window tab-by-tab as you are now.

OK then. I didn’t know. You asked for “more options”, so thought I’d mention BBEdit.

Personally, I don’t think it’s worth spending any more time on. I always save my scripts as I go (like I do with any type of document), so when it comes time to quit it is not an issue.

I think you probably have bigger fish to fry. :wink:

Hey Folks,

Keep in mind that Script Debugger is scriptable

------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2008/01/09 12:32
# dMod: 2017/05/07 00:44
# Appl: Script Debugger
# Task: Close Unsaved Documents
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Script_Debugger, @Close, @Unsaved, @Documents, @Windows
------------------------------------------------------------------------------

tell application "Script Debugger"
   set unsavedDocList to getUnsavedScriptDebuggerDocs() of me
   repeat with theDoc in unsavedDocList
      close theDoc without saving
   end repeat
end tell

------------------------------------------------------------------------------
--» HANDLERS
------------------------------------------------------------------------------
on getUnsavedScriptDebuggerDocs()
   tell application "Script Debugger"
      set unsavedDocList to {}
      set docList to documents
      repeat with theDoc in docList
         if file spec of theDoc = missing value then
            set end of unsavedDocList to (contents of theDoc)
         end if
      end repeat
      
      return unsavedDocList
      
   end tell
end getUnsavedScriptDebuggerDocs
------------------------------------------------------------------------------

I have scripts to:

A) Bring all unsaved document to the front.

B) Close all unsaved documents without saving (shown above).

C) Save State to a Dated folder
- For all saved documents.
- Save if modified.
- Create alias in saved-state folder.
- For all unsaved documents.
- Create text file in saved-state folder.
- Close without saving.

Script © allows me to hit one keyboard shortcut, quit Script Debugger, and go – without worrying about losing any work.

So — you can do a lot to make Script Debugger work the way you want it to without having to convince Mark it should work your way.


Mark – you’d think this would work, but it doesn’t:

tell application "Script Debugger"
   set docList to documents whose file spec is missing value
end tell

In contrast — this does work:

tell application "Script Debugger"
   set docList to documents whose name contains "untitled"
end tell

-Chris

OK, just a couple things, I don’t think it works consistently the way you’re describing, Mark. I will be very mindful of the state of things when I quit and how the interface works.

As for always saving and closing documents as you go, that’s probably a good way of doing things, but I end up doing the opposite. I’ll be working on a script open a new document to test a handler or a set of commands or whatever, then copy and paste back into the script. I don’t close or save that extra document because I don’t know if I’ll want to go back to it or not. I may also open other scripts to copy and paste things I’ve used before (but not often enough to be a clipping or library). So I sometimes end up with five or 6 windows some with 5 or 6 tabs. May not be the most efficient but it works for me. Except when it’s quitting time, and with SD that’s a bit frustrating.

As for BBEdit, I believe when you quit that it just quits and remembers its state, so when you relaunch all your windows reappear. That can be nice, but it can also be a pain.

I’ve written a script for BBEdit that brings every window to the front and asks if you want to close and save. If you click cancel, it leaves that window open and goes on to the next.

I tried doing that with SD but it didn’t seem to work as well, but with this new version it might.

I’ll try a version of Chris’ script that closes asking to save, rather than closing without saving.

But still, I’d prefer more flexibility built in to the UI.

But I agree, there are probably bigger fish to be fried

Whoops! I seem to have stumbled onto a crashing bug here.

I had a window with numerous tabs (6 or so) with unsaved scripts. I clicked the close button and got the dialog that gave me a checklist of which windows to save and which to close without saving.

I doubled-clicked on one of the files to see if that would bring that tab to the front to see if it was one I wanted to close or save (it didn’t). So I clicked “Cancel.” a few seconds later SD crashed.

Happened twice in a row. Send crash reports in SD.

Can anyone replicate?

–>Script Debugger 6.0.5 (6A202) on Mac OS 10.10.5 (14F27)