Subject: 31.0.50; tsx-ts-mode has wonky text motions and indentation

From: Arsen Arsenović <[email-masked]>
Date: Tue, 31 Dec 2024 02:38:24 +0100

Hi!

It seems that, since recently, Emacs has started getting confused in
tsx-ts-mode.  For instance, text motions appear to be wrong.

Reproduction steps:

1. Insert the following into a tsx-ts-mode buffer:
--8<---------------cut here---------------start------------->8---
function F() {
  return (
    <H>Delete</H>
  );
}
--8<---------------cut here---------------end--------------->8---
2. Install tree-sitter-tsx v0.23.2
3. M-x tsx-ts-mode RET
3. M-: (goto-char 39) RET  (somewhere in the middle of "Delete")
4. M-b
5. Observe that point is not at the start of "Delete"

Following that, alter <H> to be <H foo="bar"> and hit RET at the start
of "Delete", at this point you should see:

--8<---------------cut here---------------start------------->8---
function F() {
  return (
    <H foo="bar">
		   Delete</H>
  );
}
--8<---------------cut here---------------end--------------->8---

This is unusual.

In addition, I just noticed one more thing; make a new file containing:

--8<---------------cut here---------------start------------->8---
function F() {
  return (
    <H>Delete</H>
  );
}
--8<---------------cut here---------------end--------------->8---

Navigate to the start of "Delete", run M-x treesit-explore RET, hit RET
and tell the explorer to highlight the jsx_text corresponding to
"Delete", you should see that the region highlighted is not aligned with
the end of the word "Delete", and, in turn, all subsequent AST nodes are
mispositioned too.  Typing again fixes this issue.  It seems that the
buffer needs to be freshly-started for this to happen for some reason.

I do not have any idea why this might be happening.

Thanks in advance, and happy holidays!

In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.18.2, Xaw3d scroll bars) of 2024-12-31 built on localhost
Repository revision: 2f1052d9b0de551dc3a463ed54e21c63517497ab
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12401004
System Description: Gentoo Linux

Configured using:
 'configure --prefix=/usr --build=x86_64-pc-linux-gnu
 --host=x86_64-pc-linux-gnu --mandir=/usr/share/man
 --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc
 --localstatedir=/var/lib --datarootdir=/usr/share
 --disable-silent-rules --docdir=/usr/share/doc/emacs-31.0.9999
 --htmldir=/usr/share/doc/emacs-31.0.9999/html --libdir=/usr/lib64
 --program-suffix=-emacs-31-vcs --includedir=/usr/include/emacs-31-vcs
 --infodir=/usr/share/info/emacs-31-vcs --localstatedir=/var
 --enable-locallisppath=/etc/emacs:/usr/share/emacs/site-lisp
 --without-compress-install --without-hesiod --without-pop
 --with-file-notification=inotify --with-pdumper --enable-acl
 --enable-xattr --with-dbus --with-modules --with-gameuser=:gamestat
 --with-libgmp --with-gpm --with-native-compilation=aot
 --without-kerberos --without-kerberos5 --with-lcms2 --with-xml2
 --with-mailutils --without-selinux --with-sqlite3 --with-gnutls
 --with-libsystemd --with-threads --with-tree-sitter --without-wide-int
 --with-sound=alsa --with-zlib --with-x --without-pgtk --without-ns
 --without-gconf --without-gsettings --with-toolkit-scroll-bars
 --with-xpm --with-xft --with-cairo --with-harfbuzz --with-libotf
 --with-m17n-flt --with-x-toolkit=lucid --with-xaw3d --with-gif
 --with-jpeg --with-png --with-rsvg --with-tiff --with-webp
 --without-imagemagick --with-dumping=pdumper 'CFLAGS=-freport-bug -O2
 -ggdb3 -pipe -fdiagnostics-color=always -march=x86-64-v2 -flto
 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing
 -fuse-ld=mold -Wl,--undefined-version -fno-fast-math -ffp-contract=off'
 CPPFLAGS= 'LDFLAGS=-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs
 -O2 -Wl,-O3 -pipe -fdiagnostics-color=always
 -Wl,--defsym=__gentoo_check_ldflags__=0 -Wl,-z,pack-relative-relocs
 -Wl,--build-id -flto -Werror=odr -Werror=lto-type-mismatch
 -Werror=strict-aliasing -fuse-ld=mold -Wl,--undefined-version''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM HARFBUZZ JPEG LCMS2
LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP X11 XAW3D XDBE XIM XINPUT2 XPM LUCID ZLIB

Important settings:
  value of $LC_TIME: en_GB.UTF-8
  value of $LANG: en_US.utf8
  locale-coding-system: utf-8-unix

Major mode: TypeScript[TSX]

Minor modes in effect:
  global-jinx-mode: t
  jinx-mode: t
  server-mode: t
  display-line-numbers-mode: t
  ruler-mode: t
  indent-bars--ts-mode: t
  indent-bars-mode: t
  diff-hl-flydiff-mode: t
  diff-hl-mode: t
  hl-todo-mode: t
  savehist-mode: t
  save-place-mode: t
  global-hl-line-mode: t
  mu4e-modeline-mode: t
  ws-butler-global-mode: t
  ws-butler-mode: t
  corfu-popupinfo-mode: t
  global-corfu-mode: t
  corfu-mode: t
  marginalia-mode: t
  vertico-mouse-mode: t
  vertico-mode: t
  org-roam-db-autosync-mode: t
  which-key-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  global-display-fill-column-indicator-mode: t
  display-fill-column-indicator-mode: t
  which-function-mode: t
  electric-pair-mode: t
  global-whitespace-mode: t
  whitespace-mode: t
  repeat-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  column-number-mode: t
  line-number-mode: t
  auto-fill-function: do-auto-fill
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/usr/share/emacs/site-lisp/emacs-eat/eat hides /usr/share/emacs/site-lisp/emacs-eat/term/eat
/usr/share/emacs/site-lisp/transient/transient hides /usr/share/emacs/31.0.50/lisp/transient
/usr/share/emacs/site-lisp/compat/compat hides /usr/share/emacs/31.0.50/lisp/emacs-lisp/compat

Features:
(shadow sort mail-extr emacsbug ebuild-mode skeleton typescript-ts-mode
js c-ts-common cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs tramp-archive tramp-gvfs
vertico-directory jinx server paredit display-line-numbers ruler-mode
indent-bars-ts indent-bars cus-edit cus-start face-remap diff-hl-flydiff
diff-hl log-view log-edit add-log pcvs-util vc-dir ewoc vc vc-dispatcher
diff-mode track-changes hl-todo savehist saveplace tramp-cache
time-stamp tramp-sh tramp trampver tramp-integration files-x
tramp-message tramp-compat shell tramp-loaddefs desktop frameset mu4e
mu4e-org mu4e-notification notifications mu4e-main smtpmail mu4e-view
mu4e-mime-parts mu4e-headers mu4e-thread mu4e-actions mu4e-compose
mu4e-draft gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime
gnutls dig gnus-sum gnus-group gnus-undo gnus-start gnus-dbus gnus-cloud
nnimap nnmail mail-source utf7 nnoo parse-time iso8601 gnus-spec
gnus-int gnus-range gnus-win gnus nnheader range wid-edit mu4e-search
mu4e-lists mu4e-bookmarks mu4e-mark mu4e-message shr pixel-fill kinsoku
url-file browse-url url url-proxy url-privacy url-expand url-methods
url-history url-cookie generate-lisp-file url-domsuf url-util flow-fill
mule-util hl-line mu4e-contacts mu4e-update mu4e-folders mu4e-context
mu4e-query-items mu4e-server mu4e-modeline mu4e-vars mu4e-helpers
mu4e-config mu4e-window bookmark pp ido message sendmail mailcap
yank-media puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg
rfc6068 epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse
rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev
mail-utils gmm-utils mailheader mu4e-obsolete auth-source-pass ws-butler
modus-vivendi-tinted-theme modus-themes kind-icon svg-lib svg dom
corfu-popupinfo corfu orderless marginalia vertico-mouse vertico
flycheck lisp-mnt emacsql-sqlite-builtin sqlite comp comp-cstr warnings
org-roam-migrate org-roam-log org-roam-mode org-roam-capture org-roam-id
org-roam-node org-roam-db org-roam-utils org-roam-compat org-roam
org-capture org-element org-persist xdg avl-tree generator org-attach
org-id org-refile org-element-ast inline org-clock dbus comp-run
comp-common xml org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro
org-src sh-script smie treesit executable ob-comint org-pcomplete
pcomplete org-list org-footnote org-faces org-entities time-date
org-version ob-emacs-lisp ob-core ob-eval org-cycle org-table ol
org-fold org-fold-core org-keys oc org-loaddefs find-func cal-menu
calendar cal-loaddefs org-compat org-macs emacsql-sqlite emacsql
emacsql-compiler magit-section format-spec cursor-sensor compat dash
cus-load which-key ace-window avy undo-tree diff queue
display-fill-column-indicator which-func imenu elec-pair whitespace
markdown-mode edit-indirect rx color url-parse auth-source eieio
eieio-core password-cache json map url-vars thingatpt noutline outline
icons repeat edmacro kmacro byte-opt cl-macs gv cl-extra help-mode
cl-seq use-package use-package-ensure use-package-delight
use-package-diminish use-package-bind-key bind-key easy-mmode
use-package-core bytecomp byte-compile site-gentoo hs-lint compile
text-property-search comint subr-x ansi-osc ansi-color ring
preview-latex mmm-auto mmm-vars cl-loaddefs cl-lib mmm-utils mmm-compat
ess-autoloads tex-site rmc iso-transl tooltip cconv eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd touch-screen 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 nadvice seq simple cl-generic
indonesian philippine 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 abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting font-render-setting cairo x-toolkit xinput2 x multi-tty
move-toolbar make-network-process tty-child-frames native-compile emacs)

Memory information:
((conses 16 544069 703495) (symbols 48 38898 315) (strings 32 154233 56412)
 (string-bytes 1 5655043) (vectors 16 61204) (vector-slots 8 756127 350607)

-- 
Arsen Arsenović