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

Bug: Incorrect wrapping when useTabs: true, assumes tab is 0 width #268

Closed
OiYouYeahYou opened this issue Aug 1, 2021 · 3 comments · Fixed by #270
Closed

Bug: Incorrect wrapping when useTabs: true, assumes tab is 0 width #268

OiYouYeahYou opened this issue Aug 1, 2021 · 3 comments · Fixed by #270

Comments

@OiYouYeahYou
Copy link
Collaborator

Info

Tool Version
Plugin ^1.16.0-0
Prettier ^2.3.2
Framework none
Node 12
OS linux

Prettier config

useTabs: true
tabWidth: 8 # Just for example

Input

p
	input#some-very-long-id-for-example-sake(type="input", placeeholder="example")

Output or Error

p
	input#some-very-long-id-for-example-sake(type="input", placeeholder="example")

Formatting with spaces instead of tabs

p
        input#some-very-long-id-for-example-sake(
                type="input",
                placeeholder="example"
        )

Expected Output

p
	input#some-very-long-id-for-example-sake(
		type="input",
		placeeholder="example"
	)

Additional Context

When using useTabs: false, it wraps correctly. Otherwsie wrapping doesn't account of the indent width and just assumes 0-width tabs.

@OiYouYeahYou
Copy link
Collaborator Author

I've been working on the indentation tests and this triggers the problem.

doctype html
html
 head
 body
       #indentation-tests
          .short(style="display: none") Hello World
          .getting-longer(style="display: none") I can't just say "Hello World" here
          .i-am-not-being-creative-with-these-names(style="display: none", color="red").
                  There is surely more I could write here
          .short-again(style="display: none", color="red", font="Sans Serif")
                  | I could surely more I could write here
                  
          .hi(
                  data-wrap="false"
          ) This should be wrapped

       section#contact
          .container
           h3 Contact
           form(name="contact", method="POST")
               .row.gtr-uniform
                 .col-6.col-12-x-small
                   input#name(type="text", name="name", placeholder="Name *", required )
                 .col-6.col-12-x-small
                   input#email( type="email", name="email", placeholder="Email *", required )
                 .col-12
                   input#subject( type="text", name="subject", placeholder="Subject *", required )
                 .col-12
                   textarea#message( name="message", placeholder="Message *", rows="6", required )
                 .col-12
                   ul.actions
                      li
                        input.primary( type="submit", value="Send Message" )
                      li
                        input( type="reset", value="Reset Form" )

Which produces a diff of:

$ diff .idea/test-2-{spaces,tabs}.pug
69,74c69
<               input#name(
<                 type="text",
<                 name="name",
<                 placeholder="Name *",
<                 required
<               )
---
>               input#name(type="text", name="name", placeholder="Name *", required)
76,81c71
<               input#email(
<                 type="email",
<                 name="email",
<                 placeholder="Email *",
<                 required
<               )
---
>               input#email(type="email", name="email", placeholder="Email *", required)

@bminer
Copy link

bminer commented Jan 8, 2025

This is still a bug. Should I open a new issue?

@Shinigami92
Copy link
Member

This is still a bug. Should I open a new issue?

Yeah, either please open a new one with new example or directly open a PR

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