Place Cursor not working for at least one case

This might only be the case when the focus is already in the editor…

When I’m editing a draft, then click on an action on my toolbar to go to Last Draft, it doesn’t matter that my setting for “Place Cursor” is “Last”, it always drops me at the Bottom of the draft.

(The script for Last Draft action is simply editor.load(editor.recentDrafts[0]))

1 Like

Note: it looks like you might have pasted in editor.load(editor.recentDrafts[0]) twice there.

Confirming I get the same result on Drafts v39.2 (264) on macOS 13.4 with the same settings and scripted action.

That is intended behavior. Cursor placement is only automatically applied when loading in the UI, the assumption being scripting a load you can already apply an appropriate range selection in the script as desired.

(Note the same is true for the related “Focus Editor” option, as it’s really a separate step to activate the editor you may or may not want to apply in a script)

Interesting to know that this is expected behaviour. If anyone’s interested, if you change the last draft action to something like
app.openURL(editor.recentDrafts[0].permalink)
you won’t get sent to the bottom of the draft. This is based on 10 minutes playing around this afternoon, so your mileage may vary, :smiling_face:.

That last suggestion didn’t work for me.

@agiletortoise is there or could there be a property or navigation marker I could access via script to place the cursor properly in the last active location?

(ps the Navigation Patterns link at the bottom of Navigation | Drafts User Guide doesn’t work)