Subject: bug#65134: closed (Re: bug#65134: [PATCH] * lisp/progmodes/js.el Fix js-ts-mode indent bug in JSX expressions)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 10 Aug 2023 09:04:02 +0000

Your bug report

#65134: [PATCH] * lisp/progmodes/js.el Fix js-ts-mode indent bug in JSX expressions

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].

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

Subject: Re: bug#65134: [PATCH] * lisp/progmodes/js.el Fix js-ts-mode indent bug in JSX expressions
From: Eli Zaretskii <[email-masked]>
To: Vincenzo Pupillo <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Thu, 10 Aug 2023 12:03:16 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Vincenzo Pupillo <[email-masked]>
> Date: Tue, 08 Aug 2023 11:22:29 +0200
> 
> I confirm the bug and that the patch fixes it.
> Thank you Danny.

Thanks for the patch and the review.  I've now installed this on the
emacs-29 branch, and I'm therefore closing the bug.

Subject: [PATCH] * lisp/progmodes/js.el Fix js-ts-mode indent bug in JSX expressions
From: Danny Freeman <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Mon, 07 Aug 2023 16:10:13 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Tags: patch

Hello,

I have a patch for a bug I found in js-ts-mode.
When editing jsx blocks, the indentation does not work.

For example, in a file with the following file with JSX code in it
and js-ts-mode enabled

```
function App() {
  return (
    <div className="App">
    </div>
  );
}
```

placing your cursor at the end of the opening div tag and pressing ENTER
does not indent, instead there is no indentation.

This patch corrects that by properly expanding the
`js-jsx--treesit-indent-compatibility-bb1f97b' function, which returns
some indent rules.

>From c13be16dd796c981455e99af5597d7861ed10631 Mon Sep 17 00:00:00 2001
From: dannyfreeman <[email-masked]>
Date: Mon, 7 Aug 2023 15:55:27 -0400
Subject: [PATCH] * lisp/progmodes/js.el Fix js-ts-mode indent bug in JSX
 expressions

Properly expand the indentation rules. Before this change, treesit
indent mechanisms were trying to call this compatability function like a
matching or anchor rule. This resulted in an error when running
`indent-for-tab-command` while the cursor was in a JSX expression.

"treesit--simple-indent-eval: Wrong number of
arguments: ((cl-struct-js--pitem-tags ido-cur-list t) nil "Indent rules
helper, to handle different releases of tree-sitter-javascript."
---
 lisp/progmodes/js.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el
index f2d7d3d3ecb..c7a031697f1 100644
--- a/lisp/progmodes/js.el
+++ b/lisp/progmodes/js.el
@@ -3474,7 +3474,7 @@ js--treesit-indent-rules
        ((parent-is "statement_block") parent-bol js-indent-level)
 
        ;; JSX
-       (js-jsx--treesit-indent-compatibility-bb1f97b)
+       ,@(js-jsx--treesit-indent-compatibility-bb1f97b)
        ((node-is "jsx_closing_element") parent 0)
        ((match "jsx_element" "statement") parent js-indent-level)
        ((parent-is "jsx_element") parent js-indent-level)
-- 
2.40.1

Thank you,
-- 
Danny Freeman