From: Danny Freeman via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 65134@debbugs.gnu.org
Cc: v.pupillo@gmail.com
Subject: bug#65134: [PATCH] * lisp/progmodes/js.el Fix js-ts-mode indent bug in JSX expressions
Date: Mon, 07 Aug 2023 16:10:13 -0400 [thread overview]
Message-ID: <87tttak40q.fsf@dfreeman.email> (raw)
[-- 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
next reply other threads:[~2023-08-07 20:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-07 20:10 Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-08-08 9:22 ` bug#65134: [PATCH] * lisp/progmodes/js.el Fix js-ts-mode indent bug in JSX expressions Vincenzo Pupillo
2023-08-10 9:03 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tttak40q.fsf@dfreeman.email \
--to=bug-gnu-emacs@gnu.org \
--cc=65134@debbugs.gnu.org \
--cc=danny@dfreeman.email \
--cc=v.pupillo@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).