racket / drracket

DrRacket, IDE for Racket
http://www.racket-lang.org/
Other
445 stars 93 forks source link

Auto formatter should not format ; comments #515

Closed jestarray closed 1 year ago

jestarray commented 2 years ago

https://user-images.githubusercontent.com/34615798/135485990-abb9e141-e784-49eb-96e6-632ad5902f75.mp4

The auto formatter currently moves single ; comments but for ;; it won't. Nonetheless it's kind of jarring to have comments be formatted

sorawee commented 2 years ago

Technically, this is called auto indenter. It only changes indentation. Auto formatter would be something like https://docs.racket-lang.org/fmt/.

I'm curious why you feel moving comments is bad. In your code, the comments are indented incorrectly relative to the surrounding code. If you want the content of these comments to be indented further, you would need to put space after ;.

#lang racket/base

;      ctrl+i now won't do anything
;              test

(define (test)
  ;; this is the right level relative to the surrounding code
  1)

Also, I don't think your observation about ; vs ;; is correct. The indenter moves both ; and ;;, provided that they are on their own. But if you have ; or ;; after some text, the indenter will indent the text.

    ;; this will be moved
hello      ;; this will not be moved because hello is already indented correctly
      world     ;; this will be moved because world is not indented correctly

And FWIW, most indenters and formatters for most languages do move comments. They don't modify the comment content, however, which is also the case for DrRacket.