atom-community / atom-community/atom-ide-markdown-service
Function `highlightTreeSitter` fails to markup long code
- Dominant language
- TypeScript
- Stars
- 12
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
Execution was success:
```js
await highlightTreeSitter(`function () {console.log()}\n`.repeat(30), 'source.js')
```
```HTML
function () {consolelog()}
...
function () {consolelog()}
```
**Randomly** fail:
```js
await highlightTreeSitter(`function () {console.log()}\n`.repeat(80), 'source.js')
```
Completely fail:
```js
await highlightTreeSitter(`function () {console.log()}\n`.repeat(120), 'source.js')
```
```HTML
function () {console.log()}
function () {console.log()}
...
function () {console.log()}
```
As far as I've tested locally, adding something like `await delay (100)` after `buf.setText (sourceCode)` in the implementation seems to work as expected.
https://github.com/atom-community/atom-ide-markdown-service/blob/6ef490f27ea173511f1a9ea449f2f693f3a9e9e5/src/highlighter.ts#L33-L35
```js
const delay = ms => new Promise(resolve=>setTimeout(resolve, ms))
```
```js
buf.setLanguageMode(lm)
buf.setText(sourceCode)
await delay(100) // <- add this line
const end = buf.getEndPosition()
```
Contributor guide
Research direction
Start in src/highlighter.ts around the buf.setLanguageMode and buf.setText calls, then run the JavaScript examples from the issue with repeated input lengths of 30, 80, and 120 lines. Trace when the syntax tree becomes available and verify that long inputs consistently receive the same markup as short inputs without timing-dependent failures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100