diff options
| author | Mattias EngdegÄrd | 2023-06-16 12:37:07 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2023-06-16 12:58:57 +0200 |
| commit | 8657afac774f36777d0fdd368e0bec64beca22ae (patch) | |
| tree | be7d0013e0a0732b2849c14f920d8c98a2fafb58 /test/src | |
| parent | f2aae8b879baa4986b69af7ee54fe4eb987b99d6 (diff) | |
| download | emacs-8657afac774f36777d0fdd368e0bec64beca22ae.tar.gz emacs-8657afac774f36777d0fdd368e0bec64beca22ae.zip | |
Correct conversion of strings to tree-sitter query syntax
The treesitter query syntax for string literals differs from that of
Elisp so we cannot just use the Lisp printer (bug#64017).
* src/treesit.c (treesit_query_string_string): New function.
(Ftreesit_pattern_expand): Use it.
* test/src/treesit-tests.el (treesit-query-api): Add test case.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/treesit-tests.el | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/test/src/treesit-tests.el b/test/src/treesit-tests.el index 7a8e53924eb..04aa91ddca6 100644 --- a/test/src/treesit-tests.el +++ b/test/src/treesit-tests.el | |||
| @@ -461,7 +461,12 @@ BODY is the test body." | |||
| 461 | "(type field: (_) @capture .) ? * + \"return\"" | 461 | "(type field: (_) @capture .) ? * + \"return\"" |
| 462 | (treesit-query-expand | 462 | (treesit-query-expand |
| 463 | '((type field: (_) @capture :anchor) | 463 | '((type field: (_) @capture :anchor) |
| 464 | :? :* :+ "return"))))))) | 464 | :? :* :+ "return")))) |
| 465 | |||
| 466 | ;; Test string conversion in `treesit-pattern-expand'. | ||
| 467 | (should (equal | ||
| 468 | (treesit-pattern-expand "a\nb\rc\td\0e\"f\1g") | ||
| 469 | "\"a\\nb\\rc\\td\\0e\\\"f\1g\""))))) | ||
| 465 | 470 | ||
| 466 | ;;; Narrow | 471 | ;;; Narrow |
| 467 | 472 | ||