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] [Formatter] Max line length value seems to be off a few chars on lines with indentation #580

Closed
3 tasks done
christopherpickering opened this issue Apr 3, 2023 · 2 comments · Fixed by #581
Closed
3 tasks done
Labels

Comments

@christopherpickering
Copy link
Contributor

With the following HTML (from the demo):

Welcome to djLint online!

Welcome to djLint online!

.length = 36

I expect, if I set the max line length to 35, to have the line reformatted, but it doesn't work.

Another example:

image

Only lines with leading indent seem to be affected.

@christopherpickering christopherpickering added 🦠 bug Something isn't working 🧽 formatter labels Apr 3, 2023
christopherpickering added a commit that referenced this issue Apr 3, 2023
…espected on indented lines

Previously this calculation was done before indentation was applied. It is updated to do the update
after indentation is applied.

closes #580
@christopherpickering
Copy link
Contributor Author

@kopax-polyconseil I pushed a few updates to the dev branch - would you be able to test it out on your code?

Take a look at the diff on the tests here to see kind of what to expect.

Previously the function that consolidated short lines was being called before the indenter, now I'm calling it after the indenter, plus fixed up the regex a bit.

There are a few things to note

  • djlint is not smart enough to flatten out nested tags
  • template tags will only be consolidated if they have a leading space or at the beginning of a line. There are too many whitespace issues around template tags to handle w/ this regex I think.

christopherpickering pushed a commit that referenced this issue Apr 5, 2023
## [1.19.17](v1.19.16...v1.19.17) (2023-04-05)

### Bug Fixes

* **blocktrans:** allowed closing transblocks to be indented if they have a leading space ([d667273](d667273))
* **custom tags:** fixed issue where end tag for custom block was not de-indented ([fb8bf5e](fb8bf5e)), closes [#572](#572)
* **ignored code:** fixed formatting of ignore code inside django comment blocks ([120460d](120460d)), closes [#569](#569)
* **linter:** linter will now ignore {% raw %} {% endraw %} blocks ([2a6865e](2a6865e)), closes [#539](#539)
* **max line length:** fixes issues around max line length not fully respected on indented lines ([1ec6b29](1ec6b29)), closes [#580](#580)
* **preserving space:** misc improvements for the preserve leading space option ([03ee6f0](03ee6f0)), closes [#566](#566)
@christopherpickering
Copy link
Contributor Author

🎉 This issue has been resolved in version 1.19.17 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

1 participant