Something like this could work. Just ensuring that we haven’t ended back at the start of the current (degenerate) inlinetask. I don’t know if this would be the most elegant solution though. I also considered whether org-inlinetask-goto-end should really move to the point after the last line of an inlinetask (is this consistent with org-element BTW?), but that would require changes across a big part of org-inlinetask and probably complicate other things.
diff --git a/lisp/org-inlinetask.el b/lisp/org-inlinetask.el index 07aa94f32..c28f5e7b4 100644 --- a/lisp/org-inlinetask.el +++ b/lisp/org-inlinetask.el @@ -334,12 +334,15 @@ (defun org-inlinetask-hide-tasks (state) (org-inlinetask-goto-end))))) (`children (save-excursion - (while - (or (org-inlinetask-at-task-p) - (and (outline-next-heading) (org-inlinetask-at-task-p))) - (org-inlinetask-toggle-visibility) - (org-inlinetask-goto-end) - (backward-char)))))) + (let ((startpoint-at-bol -1)) + (while + (or (and (org-inlinetask-at-task-p) + (not (eq startpoint-at-bol (point-at-bol)))) + (and (outline-next-heading) (org-inlinetask-at-task-p))) + (setq startpoint-at-bol (point-at-bol)) + (org-inlinetask-toggle-visibility) + (org-inlinetask-goto-end) + (backward-char))))))) (defun org-inlinetask-remove-END-maybe () "Remove an END line when present."