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

Strange wrapping on heavily indented text #6

Closed
alexarice opened this issue Jul 31, 2024 · 5 comments
Closed

Strange wrapping on heavily indented text #6

alexarice opened this issue Jul 31, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@alexarice
Copy link
Contributor

The following (with the text being all on the same line):

\begin{definition}
  \begin{definition}
    \begin{definition}
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    \end{definition}
  \end{definition}
\end{definition}

is formatted to:

\begin{definition}
  \begin{definition}
    \begin{definition}
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
      tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
      veniam,
      quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
      consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
      cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
      non
      proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    \end{definition}
  \end{definition}
\end{definition}

I think the formatter is doing a wrapping pass followed by an indentation pass followed by another wrapping pass?

@WGUNDERWOOD
Copy link
Owner

Yes, this is expected behaviour at the moment, as the formatter alternates between wrapping and indenting as you suggest. I am hoping to restructure this to remove the multiple passes framework at some point.

@alexarice
Copy link
Contributor Author

A potential band-aid fix to this could be for line wrapping to not count the initial indent as characters, this would mean that the text starts going past 80 characters but the line width should be bounded by your indent level

@WGUNDERWOOD
Copy link
Owner

Yes this is possible but I would really like the formatter to adhere to 80 characters whenever it can. I'll think about this more.

@WGUNDERWOOD WGUNDERWOOD added the enhancement New feature or request label Aug 15, 2024
@WGUNDERWOOD
Copy link
Owner

WGUNDERWOOD commented Aug 30, 2024

I am working on a solution as part of a refactor in the one-pass branch, which does the following:

  • If a line is less than WRAP_MAX = 80 characters, it is kept.
  • Otherwise, it is wrapped to be at most WRAP_MIN = 70 characters.

This way, after the line is re-indented, it will most likely not need wrapping again. Thus

\begin{definition}
\begin{definition}
\begin{definition}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{definition}
\end{definition}
\end{definition}

is formatted to

\begin{definition}
  \begin{definition}
    \begin{definition}
      Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
      eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
      enim ad minim veniam, quis nostrud exercitation ullamco laboris
      nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
      in reprehenderit in voluptate velit esse cillum dolore eu
      fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
      proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    \end{definition}
  \end{definition}
\end{definition}

The last line is slightly longer than the others, but I think this is better.

@WGUNDERWOOD
Copy link
Owner

Implemented in 9589405. Let me know if this is still not desirable and I can reopen the issue.

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

No branches or pull requests

2 participants