LuaFormatter icon indicating copy to clipboard operation
LuaFormatter copied to clipboard

Inline functions are being treated as too long

Open Mayron opened this issue 1 year ago • 1 comments

I set column_limit to 80 and this works fine with no line breaks:

local onLogout = em:CreateEventListener("function()");

So therefore I would expect this input to not be formatted to look any difference:

local onLogout = em:CreateEventListener(function()
  db.profile.freshInstall = nil;
end);

However, the result is this:

local onLogout = em:CreateEventListener(
                   function()
    db.profile.freshInstall = nil;
  end);

The entire function seems to be considered too long due to the function's content. Can I make it so it looks like the previous sample by treating the signature of the function separately (i.e. the function() part)?

The indentation of end I can live with because I like indenting all other argument types passed to functions.

Mayron avatar Sep 17 '22 12:09 Mayron

These are all my style options:

column_limit: 80
indent_width: 2
use_tab: false
continuation_indent_width: 2
keep_simple_control_block_one_line: false
keep_simple_function_one_line: false
align_args: true
break_after_functioncall_lp: true
break_before_functioncall_rp: false
align_parameter: true
chop_down_parameter: true
break_after_functiondef_lp: true
break_before_functiondef_rp: false
align_table_field: false
break_after_table_lb: true
break_before_table_rb: true
chop_down_table: false
chop_down_kv_table: true
table_sep: ";"
break_after_operator: false
extra_sep_at_table_end: true
single_quote_to_double_quote: true
spaces_inside_table_braces: true

Mayron avatar Sep 17 '22 12:09 Mayron

'break_after_functioncall_lp' is set to true so that formatter while force add a line break after 'CreateEventListener('. (unless the args can be put in one line.)

Koihik avatar Oct 26 '22 09:10 Koihik