unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#65134: [PATCH] * lisp/progmodes/js.el Fix js-ts-mode indent bug in JSX expressions
@ 2023-08-07 20:10 Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-08-08  9:22 ` Vincenzo Pupillo
  0 siblings, 1 reply; 3+ messages in thread
From: Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-08-07 20:10 UTC (permalink / raw)
  To: 65134; +Cc: v.pupillo

[-- Attachment #1: Type: text/plain, Size: 565 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-progmodes-js.el-Fix-js-ts-mode-indent-bug-in-JS.patch --]
[-- Type: text/patch, Size: 1354 bytes --]

From c13be16dd796c981455e99af5597d7861ed10631 Mon Sep 17 00:00:00 2001
From: dannyfreeman <danny@dfreeman.email>
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


[-- Attachment #3: Type: text/plain, Size: 30 bytes --]


Thank you,
-- 
Danny Freeman

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#65134: [PATCH] * lisp/progmodes/js.el Fix js-ts-mode indent bug in JSX expressions
  2023-08-07 20:10 bug#65134: [PATCH] * lisp/progmodes/js.el Fix js-ts-mode indent bug in JSX expressions Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-08-08  9:22 ` Vincenzo Pupillo
  2023-08-10  9:03   ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Vincenzo Pupillo @ 2023-08-08  9:22 UTC (permalink / raw)
  To: 65134, danny

Hi, 
I confirm the bug and that the patch fixes it.
Thank you Danny.

Vincenzo Pupillo 

In data lunedì 7 agosto 2023 22:10:13 CEST, Danny Freeman ha scritto:
> 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.









^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#65134: [PATCH] * lisp/progmodes/js.el Fix js-ts-mode indent bug in JSX expressions
  2023-08-08  9:22 ` Vincenzo Pupillo
@ 2023-08-10  9:03   ` Eli Zaretskii
  0 siblings, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2023-08-10  9:03 UTC (permalink / raw)
  To: Vincenzo Pupillo; +Cc: danny, 65134-done

> From: Vincenzo Pupillo <v.pupillo@gmail.com>
> 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.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-10  9:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-07 20:10 bug#65134: [PATCH] * lisp/progmodes/js.el Fix js-ts-mode indent bug in JSX expressions Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-08  9:22 ` Vincenzo Pupillo
2023-08-10  9:03   ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).