calva icon indicating copy to clipboard operation
calva copied to clipboard

Funky formatting with blank lines and returns

Open sirmspencer opened this issue 10 months ago • 9 comments

Something changed recently that is messing with blank lines between forms

      ....
            (is (= (simplify-new example) (simplify-new operational)))))))))

(def scenarios-existing
...

If I do a return at the end of ))))))))) it creates a new line, then immediately formats it away.

If I do a return between the forms, it creates a new line then immediately formats it away leaving my cursor at the beginning of the second form.

The only way I can get blank lines in there to start writing the next form is to put my cursor at the beginning of the second form and hit return.

This is super annoying. Maaaayyyyybbeee could get used to it if by adding a new form on the blank line between these form, the formatter would pad the top and bottom, but it doesn't.

sirmspencer avatar Apr 16 '25 12:04 sirmspencer

Sounds hellish! Which version of Calva are you using?

PEZ avatar Apr 16 '25 13:04 PEZ

2.0.501. clojure-lsp set to latest. Went back through my settings. VSCode is saying that Calva is overwriting "formatOnType" to be true.

sirmspencer avatar Apr 16 '25 17:04 sirmspencer

I can temp fix it, but I have to manually set it to false in settings.json. The setting unchecked doesn't override the default calva is setting

What it looks like with no settings.json changes. Image

After manual settings.json changes Image

sirmspencer avatar Apr 16 '25 17:04 sirmspencer

The setting may have been this way for a while. After disabling it on whole, when I hit return inside a element, it no longer indents to the right line to start the next value.

(def test
  [1
])

This is what I expect after the same return.

(def test
  [1
   ])

sirmspencer avatar Apr 16 '25 17:04 sirmspencer

Format on type should be on if you want Calva's help to indent correctly when you enter a new line. But it shouldn't mess with you like it has started to do. What's your setting for new indent engine? I'm thinking it may be disabled, causing Calva to use it's formatter for indenting and thus triggering the bug. I could also be completely wrong about this.

cc: @pbwolf You have any clue what could be afoot here?

PEZ avatar Apr 16 '25 18:04 PEZ

new indent engine is indead off. That has not changed on my end though.

what's the difference between the two?

sirmspencer avatar Apr 16 '25 19:04 sirmspencer

What has changed is the formatter. We have some regressions. The difference between the old and the new indent engine is that the former uses the formatter, and the latter does not. So you can probably avoid the bug you are encountering by using the new indent engine (which is the default).

PEZ avatar Apr 16 '25 19:04 PEZ

Thanks, will do

sirmspencer avatar Apr 16 '25 21:04 sirmspencer

Reopened. We still need to fix the issue. 😄

PEZ avatar Apr 16 '25 21:04 PEZ