Having issues with outdent action

HI. I’m using the markdown bullet list action in combination with the indent / outdent actions. while I can indent lists with no issues, the outdent actions aren’t working. I even tried a few different outdent actions from Drafts 4 and still no luck. I think this is a new issue since I’ve been using Drafts 5 for a few weeks and am just seeing this now. Could something have changed in recent builds? I’m running latest TestFlight beta build.

Thank you

I use this script. It will outdent the list without me having to go to the beginning of the line. The built in actions didn’t work for me either, but maybe I’m missing something.

I write a lot of “outline” type lists and I got tired of moving my cursor to the beginning fo the line to add or delete tabs. This script saves me a lot of time.

// Outdent current line

(() => {
"use strict";

	const lnRange = editor.getSelectedLineRange();
	const ln = editor.getTextInRange(lnRange[0],lnRange[1]);
	const selRange = editor.getSelectedRange();

	if (ln.indexOf("\t") > -1) {	
		editor.setTextInRange(lnRange[0],lnRange[1],ln.replace(/\t/, ""));
		editor.setSelectedRange(selRange[0]-1,selRange[1]);
	};
}) ();
2 Likes

Thank you. Works great!!

I think it was believed by @agiletortoise that this had been fixed in the current Outdent action:

but as far as I can see the 2018-05-30 19:14:18 UTC version still seems to lengthen the selection where it needs to shorten it – visible, if, for example we indent and then outdent with a selection like that below.

I find that I can fix it here by correcting a (+) to a (-) in the penultimate line. (Perhaps left over from a copy-paste from the source of the indent action ?).

2018-05-30 19:14:18 UTC

ends with:

// update selection
let newStart = selStart - startAdjust;
let newLen = selLen + (indent.length * outdentCt)
editor.setSelectedRange(newStart, newLen);

but can be fixed, I think, by changing that plus in the penultimate line to a minus.

i.e. it should be:

// update selection
let newStart = selStart - startAdjust;
let newLen = selLen - (indent.length * outdentCt)
editor.setSelectedRange(newStart, newLen);

(it needs to be a minus because we are removing indents, and shifting the selection leftward)