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:
+12
-6
@@ -78,8 +78,11 @@ function M.format_document(content, options)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function get_continuation_indent()
|
local function get_continuation_indent()
|
||||||
-- Continuation is one additional indent level beyond current
|
-- Continuation indent to align parameters
|
||||||
return string.rep(indent_char, (indent_level + 1) * indent_size)
|
-- 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
|
end
|
||||||
|
|
||||||
local function get_keyword(line)
|
local function get_keyword(line)
|
||||||
@@ -218,15 +221,18 @@ function M.format_document(content, options)
|
|||||||
-- Handle FB call continuation
|
-- Handle FB call continuation
|
||||||
local formatted_line
|
local formatted_line
|
||||||
if in_fb_call then
|
if in_fb_call then
|
||||||
-- Check if this ends the FB call
|
-- Check if line ends an FB call (has closing paren without opening)
|
||||||
if not is_fb_call_inside(trimmed) then
|
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
|
formatted_line = get_continuation_indent() .. trimmed
|
||||||
in_fb_call = false
|
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
|
elseif is_fb_call_continuation(trimmed) then
|
||||||
formatted_line = get_continuation_indent() .. trimmed
|
formatted_line = get_continuation_indent() .. trimmed
|
||||||
else
|
else
|
||||||
formatted_line = get_indent() .. trimmed
|
-- Still inside FB call but not a continuation
|
||||||
|
formatted_line = get_continuation_indent() .. trimmed
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
formatted_line = get_indent() .. trimmed
|
formatted_line = get_indent() .. trimmed
|
||||||
|
|||||||
Reference in New Issue
Block a user