Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indenter and formatter not in agreement about some forms #2032

Closed
PEZ opened this issue Jan 25, 2023 · 5 comments
Closed

Indenter and formatter not in agreement about some forms #2032

PEZ opened this issue Jan 25, 2023 · 5 comments
Labels
bug Something isn't working editing formatting

Comments

@PEZ
Copy link
Collaborator

PEZ commented Jan 25, 2023

With a form like (cursor at |):

(and x |y)

Pressing enter gives

(and x 
     |y)

Which I think is expected (can't recall right now). However, if I then press tab, I get:

(and x
  |y)

So it seems like the indenter and the formatter read the config differently.

Possibly related:

That said, I am experiencing weird indentation issues quite often lately. Which could be regressions from the fixing of this issue. I'll try figure out a repro. It happens to me in my work project and code I can't share as is.

Originally posted by @PEZ in #1957 (comment)

@PEZ
Copy link
Collaborator Author

PEZ commented Jan 25, 2023

Maybe a unit test that checks that the indenter and the formatter does the same thing is called for here.

@SillyCoon
Copy link
Contributor

I'll try to identify the config for both indenter and formatter, probably the sorting fix from the deftype issue was not applied everywhere

@SillyCoon
Copy link
Contributor

Hi @PEZ! I can't reproduce it this way and Format current form also. But it reproduces in a slightly different manner:

With a form like (cursor at |):

(and x |y)

Pressing enter gives

(and x 
     |y)

I then press enter again

(and x 
     
    |y)

And then backspace

(and x 
  |y)

I guess it happens because backspaceOnWhitespaceEdit doesn't pass config to getIndent function, but I'm not sure about your case, could you please re-check it. Thanks!

@PEZ
Copy link
Collaborator Author

PEZ commented Jan 26, 2023

Ah, you are right, my repro is bad. So the error I see, happens in my work project, where we have #"\S+" [[:inner 0]] in our cljfmt.edn config. This config reproduces it:

{:indents {#"\S+" [[:inner 0]]
           ,,,}
 :test-form
 (and a b)}

It used to make both the indenter and the formatter indent like:

(and x 
  y)

But since recently it makes the indenter format it as if the regex catch-all wasn't there.

Your find with backspace is interesting. I tried it with v2.0.322 and it was the same there. Please file as a separate issue.

@SillyCoon
Copy link
Contributor

@PEZ and this one also 🙏

@bpringe bpringe closed this as completed Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working editing formatting
Projects
None yet
Development

No branches or pull requests

3 participants