Subject: bug#60169: closed (Re: bug#60169: 30.0.50; [PATCH]: Simplify jsx/tsx rules for indentation)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 17 Dec 2022 23:37:02 +0000

Your bug report

#60169: 30.0.50; [PATCH]: Simplify jsx/tsx rules for indentation

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
60169: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60169
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#60169: 30.0.50; [PATCH]: Simplify jsx/tsx rules for indentation
From: Yuan Fu <[email-masked]>
To: Theodor Thornhill <[email-masked]>
Cc: [email-masked]
Date: Sat, 17 Dec 2022 15:36:26 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Theodor Thornhill <[email-masked]> writes:

> Hi Yuan!
>
> Can you install this for me?
>
> Thanks in advance,
> Theo

Applied, thanks!

Yuan

Subject: 30.0.50; [PATCH]: Simplify jsx/tsx rules for indentation
From: Theodor Thornhill <[email-masked]>
To: [email-masked]
Date: Sat, 17 Dec 2022 23:14:08 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi Yuan!

Can you install this for me?

Thanks in advance,
Theo

>From ef710150559b2e865d918024edb6beea46d290b3 Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <[email-masked]>
Date: Sat, 17 Dec 2022 23:11:57 +0100
Subject: [PATCH] Indentation fixes for jsx/tsx

* lisp/progmodes/js.el (js--treesit-indent-rules): Simplify the rules.
* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--indent-rules): Simplify the rules
---
 lisp/progmodes/js.el                 | 11 +++++------
 lisp/progmodes/typescript-ts-mode.el | 10 +++++-----
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index a776ff91f9..8c1ee495c2 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3451,14 +3451,13 @@ js--treesit-indent-rules
        ((parent-is "statement_block") parent-bol js-indent-level)
 
        ;; JSX
-       ((parent-is "jsx_opening_element") parent js-indent-level)
-       ((match "<" "jsx_fragment") parent 0)
-       ((parent-is "jsx_fragment") parent js-indent-level)
+       ((node-is "jsx_fragment") parent typescript-ts-mode-indent-offset)
+       ((node-is "jsx_element") parent typescript-ts-mode-indent-offset)
+       ((node-is "jsx_expression") parent typescript-ts-mode-indent-offset)
+       ((node-is "jsx_self_closing_element") parent typescript-ts-mode-indent-offset)
        ((node-is "jsx_closing_element") parent 0)
-       ((node-is "jsx_text") parent js-indent-level)
-       ((parent-is "jsx_element") parent js-indent-level)
        ((node-is "/") parent 0)
-       ((parent-is "jsx_self_closing_element") parent js-indent-level)))))
+       ((node-is ">") parent 0)))))
 
 (defvar js--treesit-keywords
   '("as" "async" "await" "break" "case" "catch" "class" "const" "continue"
diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
index e7bd65c5e2..890d0a8134 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -95,13 +95,13 @@ typescript-ts-mode--indent-rules
      ((parent-is "binary_expression") parent-bol typescript-ts-mode-indent-offset)
 
      ,@(when (eq language 'tsx)
-         `(((parent-is "jsx_opening_element") parent typescript-ts-mode-indent-offset)
-           ((match "<" "jsx_fragment") parent 0)
-           ((parent-is "jsx_fragment") parent typescript-ts-mode-indent-offset)
+         `(((node-is "jsx_fragment") parent typescript-ts-mode-indent-offset)
+           ((node-is "jsx_element") parent typescript-ts-mode-indent-offset)
+           ((node-is "jsx_expression") parent typescript-ts-mode-indent-offset)
+           ((node-is "jsx_self_closing_element") parent typescript-ts-mode-indent-offset)
            ((node-is "jsx_closing_element") parent 0)
-           ((parent-is "jsx_element") parent typescript-ts-mode-indent-offset)
            ((node-is "/") parent 0)
-           ((parent-is "jsx_self_closing_element") parent typescript-ts-mode-indent-offset)))
+           ((node-is ">") parent 0)))
      (no-node parent-bol 0))))
 
 (defvar typescript-ts-mode--keywords
-- 
2.34.1