diff options
| -rw-r--r-- | lisp/progmodes/typescript-ts-mode.el | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 5389d0d64c9..edca89e5c3a 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el | |||
| @@ -596,11 +596,7 @@ at least 3 (which is the default value)." | |||
| 596 | (when (treesit-available-p) | 596 | (when (treesit-available-p) |
| 597 | (treesit-query-compile 'tsx | 597 | (treesit-query-compile 'tsx |
| 598 | '(((regex pattern: (regex_pattern) @regexp)) | 598 | '(((regex pattern: (regex_pattern) @regexp)) |
| 599 | ((variable_declarator value: (jsx_element) @jsx)) | 599 | ((jsx_text) @jsx))))) |
| 600 | ((assignment_expression right: (jsx_element) @jsx)) | ||
| 601 | ((arguments (jsx_element) @jsx)) | ||
| 602 | ((parenthesized_expression (jsx_element) @jsx)) | ||
| 603 | ((return_statement (jsx_element) @jsx)))))) | ||
| 604 | 600 | ||
| 605 | (defun typescript-ts--syntax-propertize (beg end) | 601 | (defun typescript-ts--syntax-propertize (beg end) |
| 606 | (let ((captures (treesit-query-capture 'typescript typescript-ts--s-p-query beg end))) | 602 | (let ((captures (treesit-query-capture 'typescript typescript-ts--s-p-query beg end))) |
| @@ -621,8 +617,15 @@ at least 3 (which is the default value)." | |||
| 621 | (string-to-syntax "\"/")) | 617 | (string-to-syntax "\"/")) |
| 622 | ('jsx | 618 | ('jsx |
| 623 | (string-to-syntax "|"))))) | 619 | (string-to-syntax "|"))))) |
| 624 | (put-text-property ns (1+ ns) 'syntax-table syntax) | 620 | ;; The string syntax require at least two characters (one for |
| 625 | (put-text-property (1- ne) ne 'syntax-table syntax)))) | 621 | ;; opening fence and one for closing fence). So if the string has |
| 622 | ;; only one character, we apply the whitespace syntax. The string | ||
| 623 | ;; has to be in a non-code syntax, lest the string could contain | ||
| 624 | ;; parent or brackets and messes up syntax-ppss. | ||
| 625 | (if (eq ne (1+ ns)) | ||
| 626 | (put-text-property ns ne 'syntax-table "-") | ||
| 627 | (put-text-property ns (1+ ns) 'syntax-table syntax) | ||
| 628 | (put-text-property (1- ne) ne 'syntax-table syntax))))) | ||
| 626 | 629 | ||
| 627 | (if (treesit-ready-p 'tsx) | 630 | (if (treesit-ready-p 'tsx) |
| 628 | (add-to-list 'auto-mode-alist '("\\.tsx\\'" . tsx-ts-mode))) | 631 | (add-to-list 'auto-mode-alist '("\\.tsx\\'" . tsx-ts-mode))) |