if argument list opens with explicit newline, don't inline
it would be nice if type tables, tables function declaration argument lists, and function call argument lists would be left multi-line if they have an explicit newline directly after their opening token.
the change below is why I can't deploy stylua across more directories in one of my codebases.
I'm still incredibly wary of something like this, especially as a default. As mentioned in a few other places now, if we look for an explicit newline after the opening token, whenever something expands it will never collapse again unless manually intervened (formatter reversibility).
I know you bring this up a lot, and I assume its something important to you. Personally, I don't think it is something I would implement directly into StyLua currently; I would probably gate it behind an option (which leads into the issue of configurability, but 🤷). If we went with an option, it could probably even work on a sliding scale with a few different choices:
- completely disable this heuristic, so we only take into account size. This also solves #264
- only apply it to tables (as current - probably default)
- apply to everywhere (tables, function declaration parameters, function call arguments - but, as mentioned above, these will never collapse again once expanded)
That's essentially adding 3 new configuration options (compacted into one), but I wonder if its worth it?
Going to close this original issue with the reasoning explained in https://github.com/JohnnyMorganz/StyLua/issues/248#issuecomment-1817808703. Reliance on input breaks the consistency and bikeshedding principles, so I am quite heavily against it.
An alternative solution is to make this consistent but behind an option as mentioned in the previous comment: e.g. "always expand argument lists". But, given that there hasn't been any significant demand for this, not sure if it's worth moving forward with right now. If there is sufficient demand, we could revisit.