Subject: bug#73978: 31.0.50; Text syntax applied on too many things in tsx-ts-mode

From: Juri Linkov <[email-masked]>
Date: Sun, 05 Jan 2025 10:21:25 +0200

> ReactDOM.render(
> <div>
> <h1>Hello, Welcome to React and TypeScript-!-</h1>
> </div>,
>   document.getElementById("root")
> );
>
> C-M-f moves point to
>
> ReactDOM.render(
> <div>
> <h1>Hello, Welcome to React and TypeScript</h1-!->
> </div>,
>   document.getElementById("root")
> );
>
> But maybe this is a different problem.

This can be fixed by the following patch that copied the syntax of < and >
from sgml-make-syntax-table:

diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
index 09f29a4ac65..21672d2d9c1 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -692,7 +694,11 @@ tsx-ts--syntax-propertize-captures
                                      ne t)
              (put-text-property
               (match-beginning 0) (match-end 0)
-              'syntax-table (string-to-syntax ".")))))))))
+              'syntax-table (string-to-syntax
+                             (cond
+                              ((equal (match-string 0) "<") "(<")
+                              ((equal (match-string 0) ">") "(>")
+                              (t ".")))))))))))
 
 (if (treesit-ready-p 'tsx)
     (add-to-list 'auto-mode-alist '("\\.tsx\\'" . tsx-ts-mode)))