Cursor position defaults to bottom of window

When I open a script in Script Debugger, the cursor position is always at the bottom of the window. I would prefer Script Debugger remember the cursor position, or allow a choice of it’s default position (e.g. top or bottom).

Am I missing something?

What file format? And was it last saved in Script Debugger?

Script Debugger normally sets the selection to where it was when the document was last saved.

I see the same behaviour here.

You can script SD to set the cursor like so:

tell application "Script Debugger"
	tell front document
		set selection to {1, 1}
	end tell
end tell

That’ll set it to the beginning of the document. If you use a template like I do for all new scripts, you can adjust the first number in the list {1,1} to wherever you normally start working on a new script. The snippet itself you could put in FastScripts or some other script runner.

It would be nice to have a SD preference of where to position the cursor when opening an existing document, but ⌘↑ works fine for me. Simpler than finding a script to run.

Sure, if you want it at the beginning or end, but if you want it somewhere specific, and it’s always the same place (i.e., if you use templates), it’s no chore to assign that a hotkey and invoke it straight after Command-N.

Thanks, all. The file format is .scpt (Compiled OSA Script), and was last saved in Script Debugger.

This is a minor annoyance, and would still be if I used ⌘↑ or Phil’s script upon opening a script, although I appreciate the tips.

Looks like a regression. Script Debugger is supposed to restore the selected range from when the script as last saved. As I play with it here, it seems this is no longer happening.

I’ve filed a bug at our end.

1 Like

Thanks, Mark.

Incidentally, I don’t believe I’ve mentioned that I’m just across town in Esquimalt.

1 Like

We’ll have to have coffee sometime.

Hey Mark,

That’s precisely as it should be in my opinion.

A then P

OR

A then N

Will rapidly get you to the top or bottom of your document without forcing you to move your hands to the cursor keys.

If you want to be able to move around the visible editing area with a keystroke then try out these scripts.

Move Cursor to Top, Middle, Botton of Visible Editing Area.zip (41.1 KB)

I have them bound to:

Top ...... J

Middle .... J

Bottom ... J

Old time editors like vi, and z would also let you reposition the current line in those places, but that can’t be done reliably in Script Debugger.

-Chris

FYI, it’s still working as expected if Open in Tabs is off.

Open in Tabs was and is off in my Script Debugger, but the same problem persists. I tried switching Open in Tabs on, quitting, switching it off, quitting, but no difference.

Same here.

Open a script with Open in Tabs on, cursor is at the bottom. Open the same script with open in tabs off, cursor is where I left it when window (or tab) was closed.

–>Script Debugger 6.0.4 (6A198) on Mac OS 10.11.6 (15G1217)

On further testing, with Open in Tabs off, if I open a script when Script Debugger is not already running, the cursor always goes to the bottom of the window. If Script Debugger is already running, the cursor is where it was when the file was saved.

Seems like something Mark should check out at some point.

Either way, the window always opens scrolled down as far as it can be without the cursor being hidden beyond the top of the window. So for example, with the cursor at line 20 in a 200 line script, the window scrolls on opening so the cursor is at the top of the window. A bit hard to describe, and I’m not sure if that’s the intended behaviour.