Subject: bug#64647: treesit-query-error due to a recent change to tree-sitter-javascript grammar definition

From: Theodor Thornhill <[email-masked]>
Date: Sat, 22 Jul 2023 13:56:04 +0200

Vincenzo Pupillo <[email-masked]> writes:

> In data mercoledì 19 luglio 2023 07:11:05 CEST, Theodor Thornhill ha scritto:
>
>> For Typescript these changes should go into 'tsx-ts-mode, not
>> 'typescript-ts-mode. That may be why you are seeing some strange results?
> No, exactly the same problem occurs, unfortunately. After all, the sources of 
> libtree-sitter-tsx and libtree-sitter-typescript come from the same repository 
> and the content of  tree-sitter-typescript/tsx/grammar.js is just that:
> const defineGrammar = require('../common/define-grammar');
> module.exports = defineGrammar('tsx');
>
>
>> > ---
>> 
>> "... function to handle ..."
>
> fixed

Thanks for the fixes :)

>
>
> Sorry for the error. I fixed them, tested and fixed the function names according to your instructions (also in js.el)
> Hope the patches are better now.
> Thanks.
> Vincenzo
>

No worries! Am I correct in that this patch should be applied as well?
If you agree, I'll just apply it myself, no need to make a new patch.

Theo

diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
index 173ec52f209..39fcd1de30e 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -75,10 +75,10 @@ typescript-ts-mode--syntax-table
     table)
   "Syntax table for `typescript-ts-mode'.")
 
-(defun tsx-ts-mode--indent-compatibility-b893426 ()
+(defun tsx-ts-mode--indent-compatibility-bb1f97b ()
   "Indent rules helper, to handle different releases of tree-sitter-tsx.
 Check if a node type is available, then return the right indent rules."
-  ;; handle commit b893426
+  ;; handle commit bb1f97b
   (condition-case nil
       (progn (treesit-query-capture 'tsx '((jsx_fragment) @capture))
              `(((match "<" "jsx_fragment") parent 0)
@@ -122,7 +122,7 @@ typescript-ts-mode--indent-rules
      ((parent-is "binary_expression") parent-bol typescript-ts-mode-indent-offset)
 
      ,@(when (eq language 'tsx)
-	 (append (tsx-ts-mode--indent-compatibility-b893426)
+	 (append (tsx-ts-mode--indent-compatibility-bb1f97b)
 		 `(((node-is "jsx_closing_element") parent 0)
 		   ((match "jsx_element" "statement") parent typescript-ts-mode-indent-offset)
 		   ((parent-is "jsx_element") parent typescript-ts-mode-indent-offset)