fix(formatter): Fix FB call continuation indent

- Use correct continuation indent formula (base + fb_name_length + 2)
- Fix closing line of FB call to use continuation indent
- Parameters on continuation lines are now aligned
This commit is contained in:
2026-02-18 14:50:49 +01:00
parent f977d1ea7c
commit eb11380aea
+12 -6
View File
@@ -78,8 +78,11 @@ function M.format_document(content, options)
end
local function get_continuation_indent()
-- Continuation is one additional indent level beyond current
return string.rep(indent_char, (indent_level + 1) * indent_size)
-- Continuation indent to align parameters
-- Aligns parameter name with position after FB name + opening paren
-- Formula: base indent + FB name length + 1 (for opening paren) + 1 (extra offset)
local base_indent = string.rep(indent_char, indent_level * indent_size)
return base_indent .. string.rep(" ", fb_name_length + 2)
end
local function get_keyword(line)
@@ -218,15 +221,18 @@ function M.format_document(content, options)
-- Handle FB call continuation
local formatted_line
if in_fb_call then
-- Check if this ends the FB call
if not is_fb_call_inside(trimmed) then
-- Check if line ends an FB call (has closing paren without opening)
local has_closing = trimmed:match(".*%)")
if has_closing and not trimmed:match("%(") then
-- This line closes the FB call
formatted_line = get_continuation_indent() .. trimmed
in_fb_call = false
-- Check if this is a continuation line
-- Check if this is a continuation line (ends with ,)
elseif is_fb_call_continuation(trimmed) then
formatted_line = get_continuation_indent() .. trimmed
else
formatted_line = get_indent() .. trimmed
-- Still inside FB call but not a continuation
formatted_line = get_continuation_indent() .. trimmed
end
else
formatted_line = get_indent() .. trimmed