"Jacob S. Gordon" <[email protected]> writes:

> With a large number of tasks / checklist items (N > 100), the percent
> completion statistic can show 0% even if some of the tasks are
> complete, e.g. 1/101
>
> - [0%]
>   1. [X]
>   2. [ ]
>   3. [ ]
>   --8<--
>   101. [ ]
>
> Personally, I find this misleading and I’d rather it show 1% (which
> would make it symmetric with 200/201 showing 99% instead of 100%).
> With the attached patch, small percentages 0% < p < 1% are rounded up
> to 1% instead of down to 0%:
>
>   (let* ((p (floor (* 100.0 completed) (max 1 total)))
>          (p (if (and (= p 0) (> completed 0)) 1 p)))
>          (format "[%d%]" p))
>
> I’ve also added some tests.  Any thoughts on this behaviour?

This looks harmless, and reasonable, although technically breaking (and
thus warrants ORG-NEWS entry).

Let's wait for feedback.

> +            (if percent
> +                (let ((p (floor (* 100.0 checked) (max 1 total))))
> +                  (format "[%d%%]" (if (and (= p 0) (> checked 0))
> +                                       1 p)))
> ...
> +                     (let ((p (floor (* 100.0 cnt-done) (max 1 cnt-all))))
> +                       (format "[%d%%]" (if (and (= p 0) (> cnt-done 0))
> +                                            1 p)))
> +                   (format "[%d/%d]" cnt-done cnt-all))

Maybe it warrants a small helper function rather than code
duplication. Mostly because the exact behavior is a judgment call and
may be missed during refactoring.

-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

Reply via email to