incorrect token positions with tabs
- Dominant language
- TypeScript
- Stars
- 5.3k
- Forks
- 363
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 3
Description
It seems using options.tabWidth with a value other than 1 when generating sourceWithoutTabs will result in token start positions which do not match the original source string.
Here is the line in question:
https://github.com/benjamn/recast/blob/52a7ec3eaaa37e78436841ed8afc948033a86252/lib/parser.js#L20
Shouldn't this always be `tabWidth: 1`?
For instance if you parse the following with a `tabWidth: 4`
```
function foo(bar) {
return bar;
}
```
The resulting token list has the `return` token at `start: 24` when it should be 21.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at lib/parser.js line 20 and reproduce the issue by parsing the supplied function with tabWidth: 4. Compare the resulting token positions with offsets in the original source, especially the return token. Done means sourceWithoutTabs handling preserves the original token start position, with return reported at 21.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100