formatter breaks code that has comments
- Dominant language
- JavaScript
- Stars
- 507
- Forks
- 45
- Avg merge
- 11h 22m
- Merged PRs (30d)
- 4
Description
```js
const code = `
(define i 0) ;;
(define i (let ((i 2)) (+ i 3)))
`;
async function main() {
/* this is head of devel branch when I wrote this */
const lips = await import("https://cdn.jsdelivr.net/gh/jcubic/lips@74055b5a1172ff48e3fe075e319142b840c492c1/dist/lips.esm.min.js");
console.log(code);
console.log(new lips.Formatter(code).break().format());
}
main();
```
it prints that the formatted code is
```scheme
(define i 0)
;; (define i (let ((i 2))
(+ i 3)))
```
which is syntax error.
if the initial code is this:
```scheme
(define i 0) ;;
(define i 1)
```
the formatted output is:
```scheme
(define i 0)
```
which is syntactically correct but not complete.
Contributor guide
Research direction
Start with the Formatter entry point shown in the reproduction: new lips.Formatter(code).break().format(). Run both supplied Scheme snippets and compare the formatted output with the input, focusing on comments and the code following them. Done means comments are preserved without commenting out or dropping subsequent forms, and the result remains syntactically complete.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100