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

Should Indentation decrease on the same line as closing symbols if the line is not otherwise empty? #32

Open
cdesaintguilhem opened this issue Oct 3, 2024 · 5 comments

Comments

@cdesaintguilhem
Copy link
Contributor

cdesaintguilhem commented Oct 3, 2024

I've noticed that indentation is decreased on the same line as a closing curly bracket, as in the following raw source:

\comment{This is a comment
that the user has decided
to write on different lines.}

gets indented as

\comment{This is a comment
  that the user has decided
to write on different lines.}

I would expect it to also indent the last line that contains the closing bracket and give:

\comment{This is a comment
  that the user has decided
  to write on different lines.}

An alternative would be to instead to insert line breaks to obtain

\comment{
  This is a comment
  that the user has decided
  to write on different lines.
}

but the latter would be a different style choice than what the user might want (also potentially introduce errors by not having a % after the opening brace).

PS. I just discovered this new formatter and I'm excited to give it a spin! I'll try to contribute test cases if I find any interesting ones.

@cdesaintguilhem cdesaintguilhem changed the title [Bug?] Indentation decreases on the same line as closing curly brackets Should Indentation decrease on the same line as closing symbols if the line is not otherwise empty? Oct 3, 2024
@cdesaintguilhem
Copy link
Contributor Author

I notice that in your brackets.tex test file, this is actually expected behaviour. Personally, I find it a bit odd to decrease the indent for the last line of a text or equation block and would expect the indentation to decrease only for the line afterwards (except if the closing symbol was the first non-whitespace character). Maybe this is just down to preference and it might not make sense to change the behaviour in this case, but just throwing the idea out there.

@WGUNDERWOOD
Copy link
Owner

Thanks for this! As you point out, this is currently expected behaviour, and is the style which I personally prefer. Nonetheless I would be open to including an option to dedent after the closing bracket on non-empty lines, if this is desirable for some people. I do think however that adding extra line breaks is very likely to cause problems with correctness so would prefer to avoid this.

@cdesaintguilhem
Copy link
Contributor Author

Thanks for being open to the suggestion! I guess we can count this as a +1 from me for such an option, but I appreciate that it might not be worth your time until this is a more popular request. If I have some time I might tinker around and suggest an implementation at some point.

Regarding adding line breaks, I agree that this is undesirable and it should be left to the user.

@WGUNDERWOOD
Copy link
Owner

Great, I probably won't be able to work on this immediately, so feel free to suggest an implementation if you'd like to!

@WGUNDERWOOD
Copy link
Owner

I am going to close this issue for now; feel free to reopen it if you have some ideas for an implementation, or if other people are also requesting this feature.

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

No branches or pull requests

2 participants