Subject: Bug report: 'universal-argument followed by 'org-update-statistics-cookies resets stats to [0/0] when section contains a subsection in addition to checkboxes

From: Francois <[email-masked]>
Date: Mon, 3 Jul 2023 00:29:57 +0200

Consider the following org document:
* Section 1 [0/2]
- [ ] token 1.1
- [ ] token 1.2
* Section 2 [0/2]
- [ ] token 2.1
- [ ] token 2.2
** Subsection 2.1

When the cursor is in section 2, <C-c #> sets the statistics of the section
to [0/2].
But <C-u C-c #> will reset the statistics to [0/0].
This does not happen in Section 1, which has no subsection, unlike Section
2.

-----

In GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.37,
cairo version 1.16.0)
 of 2023-05-14, modified by Debian built on x86-ubc-01
Windowing system distributor 'The X.Org Foundation', version 11.0.12201009
System Description: Debian GNU/Linux 12 (bookworm)

Configured using:
 'configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/libexec
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/28.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/28.2/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils
 --with-native-compilation --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/libexec
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-libsystemd --with-pop=yes
 --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/28.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/28.2/site-lisp:/usr/share/emacs/site-lisp
 --with-sound=alsa --without-gconf --with-mailutils
 --with-native-compilation --with-cairo --with-x=yes
 --with-x-toolkit=gtk3 --with-toolkit-scroll-bars 'CFLAGS=-g -O2
 -ffile-prefix-map=/build/emacs-mPr7Vr/emacs-28.2+1=.
-fstack-protector-strong
 -Wformat -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' LDFLAGS=-Wl,-z,relro'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Org

Minor modes in effect:
  global-flycheck-mode: t
  flycheck-mode: t
  savehist-mode: t
  global-highlight-parentheses-mode: t
  highlight-parentheses-mode: t
  delete-selection-mode: t
  global-linum-mode: t
  linum-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
~/.emacs.d/lisp/linum hides /usr/share/emacs/28.2/lisp/linum
/media/francois/debian/home/francois/.emacs.d/elpa/transient-0.4.1/transient
hides /usr/share/emacs/28.2/lisp/transient
~/.emacs.d/lisp/antlr-mode hides
/usr/share/emacs/28.2/lisp/progmodes/antlr-mode

Features:
(shadow sort mail-extr eieio-opt speedbar ezimage dframe shortdoc
help-fns debbugs-gnu pcase add-log debbugs-compat debbugs soap-client
rng-xsd rng-dt rng-util xsd-regexp xml autoload radix-tree lisp-mnt
tar-mode arc-mode archive-mode mm-archive gnutls network-stream url-http
url-gw nsm url-cache url-auth vc-git diff-mode vc-dispatcher misearch
multi-isearch goto-addr view emacsbug message rmc puny rfc822 mml
mml-sec epa epg rfc6068 epg-config gnus-util rmail mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
comp comp-cstr org-element avl-tree generator cl-extra ol-rmail ol-mhe
ol-irc ol-info rmail-loaddefs rfc2047 rfc2045 ietf-drums mail-utils
mm-util mail-prsvr ol-docview doc-view jka-compr image-mode exif dired
dired-loaddefs ol-bibtex ol-bbdb ol-w3m ol-doi org-link-doi org ob
ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-footnote org-src
ob-comint org-pcomplete pcomplete org-list org-faces org-entities
noutline outline org-version ob-emacs-lisp ob-core ob-eval org-table
oc-basic bibtex iso8601 time-date ol org-keys oc org-compat org-macs
org-loaddefs format-spec cal-menu calendar cal-loaddefs cus-edit pp
cus-start cus-load wid-edit flycheck find-func help-mode rx dash init
quack thingatpt cmuscheme scheme antlr-mode compile text-property-search
comint ansi-color ring cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs yaml-mode derived edmacro
kmacro adwaita-dark-theme web-mode disp-table savehist
highlight-parentheses autopair warnings advice cl delsel linum
easy-mmode finder-inf info package browse-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf url-util
mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache json subr-x map url-vars seq
byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl
tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer cl-generic
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window text-properties overlay sha1 md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote threads dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo move-toolbar gtk x-toolkit x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 501080 53881)
 (symbols 48 32207 3)
 (strings 32 142094 8938)
 (string-bytes 1 4404807)
 (vectors 16 55732)
 (vector-slots 8 1569105 42624)
 (floats 8 206 486)
 (intervals 56 1300 369)
 (buffers 992 22))