StyLua icon indicating copy to clipboard operation
StyLua copied to clipboard

Сomment incorrectly influences formation

Open d-enk opened this issue 1 year ago • 1 comments


local arg_with_long_name, function_with_long_name

--- 1
function_with_long_name(function_with_long_name(
	arg_with_long_name, -- comment
	arg_with_long_name,
	arg_with_long_name,
	arg_with_long_name,
	arg_with_long_name,
	arg_with_long_name
))

--- 2
function_with_long_name(function_with_long_name(
	arg_with_long_name, --[[comment]]
	arg_with_long_name,
	arg_with_long_name,
	arg_with_long_name,
	arg_with_long_name,
	arg_with_long_name
))

--- 3
function_with_long_name(function_with_long_name(
	arg_with_long_name,
	arg_with_long_name,
	arg_with_long_name,
	arg_with_long_name,
	arg_with_long_name,
	arg_with_long_name
))

For 1 case formatting does not work and does not look like expected behavior.

d-enk avatar Sep 19 '23 10:09 d-enk

The problem here is we eagerly select a different codepath because of the singleline comment in the first example. It is difficult to detect this comment without being too expensive since it is nested inside another function call. Will see if there is a way to solve this without a major performance penalty.

JohnnyMorganz avatar Nov 12 '23 11:11 JohnnyMorganz