js-ts-mode block-comment auto-continuation Args out of range error
- Dominant language
- Emacs Lisp
- Stars
- 22.7k
- Forks
- 3.1k
- Avg merge
- 10h 46m
- Merged PRs (30d)
- 4
Description
### I confirm that...
- [x] I searched the issue tracker and found no similar issues.
- [x] I searched the [documentation](https://docs.doomemacs.org), [FAQ](https://docs.doomemacs.org/-/faq), [discussion board](https://doomemacs.org/discuss), and [Google](https://google.com) for solutions to my issue.
- [x] I read [the debugging guide](https://doomemacs.org/d/how2debug) and researched the issue to the best of my ability.
- [x] My issue can be observed on the latest available commit of Doom.
- [x] My issue can be observed on a stable release of Emacs (i.e. doesn't end in `.50`, `.60`, or `.90`–`.99`)
### Describe your issue
Pressing return at the end of a line inside a block comment (most likely JSDoc, but it doesn't seem to matter) in `javascript-mode` inserts a new line.
```javascript
/**
* fish|
*/
function foo() {
return 5;
}
```
becomes
```javascript
/**
* fish
* |
*/
function foo() {
return 5;
}
```
However, in `js-ts-mode`, the result is instead
```javascript
/**
* fish
|
*/
function foo() {
return 5;
}
```
with an error: `Args out of range: #, 0, 3`.
Here is the backtrace:
```elisp
Debugger entered--Lisp error: (args-out-of-range # 0 3)
match-string(0)
#f(compiled-function (n parent bol &rest _) #)(nil # 13)
treesit--simple-indent-eval((prev-adaptive-prefix nil # 13))
treesit-simple-indent(nil # 13)
treesit--indent-1()
treesit-indent()
indent-according-to-mode()
comment-indent-new-line(nil)
funcall(comment-indent-new-line nil)
(progn (funcall comment-line-break-function nil) t)
(if (and +default-want-RET-continue-comments (doom-point-in-comment-p) (functionp comment-line-break-function)) (progn (funcall comment-line-break-function nil) t))
+default--newline-indent-and-continue-comments-a()
apply(+default--newline-indent-and-continue-comments-a nil)
newline-and-indent()
funcall-interactively(newline-and-indent)
command-execute(newline-and-indent)
```
Possibly relatedly, using g w to wrap text in a block comment in `js-ts-mode` doesn't insert an asterisk, as it does in `javascript-mode`, so you end up with, for instance
```javascript
/**
* fish fish fish fish fish fish fish fish fish fish fish fish fish fish fish
fish fish fish fish fish fish fish fish fish
*/
function foo() {
return 5;
}
```
I've only started seeing this since all the JavaScript changes over the past few days. But I didn't use Tree Sitter before that.
The issues doesn't exist with line comments.
### Steps to reproduce
1. Enable the `(javascript +tree-sitter)` module.
2. Open Emacs.
3. Create a new buffer, with SPC b N.
4. Copy
```javascript
/**
* fish
*/
function foo() {
return 5;
}
```
5. Paste, with p.
6. Enter `js-ts-mode`, with SPC :, `js-ts-mode`, RET.
7. Put your cursor on the end of the `fish` line (2 G $).
8. Enter insert mode with a.
9. Press RET.
10. Observe that Emacs has inserted a totally empty line.
### System information
https://pastebin.com/URcBjn1w
Contributor guide
Assessment
This issue has not been assessed yet.