Skip to content

Incorrect Formatting for Multiline Attributes #35

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

Closed
Petercopter opened this issue Sep 27, 2022 · 5 comments
Closed

Incorrect Formatting for Multiline Attributes #35

Petercopter opened this issue Sep 27, 2022 · 5 comments

Comments

@Petercopter
Copy link

Given this code:

%ul.nav.nav-tabs.mb-4
  %li.nav-item
    %button.nav-link.active{data: { bs_toggle: 'tab', bs_target: '#file' }, type: 'button' }
      File
  %li.nav-item
    %button.nav-link{ data: { bs_toggle: 'tab', bs_target: '#video' }, type: 'button' }
      Video

The first time I save (in VSCode, format on save) I get this, which is expected:

%ul.nav.nav-tabs.mb-4
  %li.nav-item
    %button.nav-link.active{
      data: { bs_toggle: 'tab', bs_target: '#file' },
      type: 'button'
    }
      File
  %li.nav-item
    %button.nav-link{
      data: { bs_toggle: 'tab', bs_target: '#video' },
      type: 'button'
    }
      Video

But I save again, and it turns into this, which is unexpected:

%ul.nav.nav-tabs.mb-4
  %li.nav-item
    %button.nav-link.active{
data: { bs_toggle: 'tab', bs_target: '#file' },
type: 'button'
}
      File
  %li.nav-item
    %button.nav-link{
data: { bs_toggle: 'tab', bs_target: '#video' },
type: 'button'
}
      Video

So it appears the syntax_tree formatting is incorrect and not idempotent (vocabulary word!) in this case.

@kddnewton
Copy link
Member

Thank you! This is indeed a bug. I'll see what I can do.

@ledermann
Copy link

ledermann commented Dec 10, 2022

As a happy user of Prettier for Ruby, I also ran into this bug while migration from Slim to Haml. I hope it can be fixed.

@kddnewton
Copy link
Member

As a happy user of Prettier for Ruby, I also ran into this bug while migration from Slim to Haml. I hope it can be fixed.

@ledermann I'd be happy to accept any pull requests if you want to put one together.

@ledermann
Copy link

@kddnewton Have you noticed my PR? It fixes this bug.

@kddnewton
Copy link
Member

Now fixed on main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants