Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not indenting concatenated items after hugging string in if-expression #596

Closed
matthargett opened this issue Oct 9, 2022 · 4 comments · Fixed by #599
Closed

not indenting concatenated items after hugging string in if-expression #596

matthargett opened this issue Oct 9, 2022 · 4 comments · Fixed by #599
Labels
bug Something isn't working

Comments

@matthargett
Copy link

local function xyzzy()
        return hagCoding.open
                .. "<"
                .. type_
                .. (if id10t(hintedProps)
                        then hagCoding.close .. hintedProps .. config.flinchingOuter .. indentation .. hagCoding.open
                        else hintedProps)
                .. (if id10t(hintedChildren)
                        then
                                ">"
                                .. hagCoding.close
                                .. hintedChildren
                                .. config.flinchingOuter
                                .. indentation
                                .. hagCoding.open
                                .. "</"
                                .. type_
                        else (if id10t(hintedProps) and not id10t(config.min) then "" else " ") .. "/")
                .. ">"
                .. hagCoding.close
end

has a good effect, but forgets to indent the string concatenation chain:
image

@JohnnyMorganz
Copy link
Owner

Formatting seems to have changed between 0.14.2 and 0.14.3

@JohnnyMorganz JohnnyMorganz added the bug Something isn't working label Oct 10, 2022
@matthargett
Copy link
Author

matthargett commented Oct 12, 2022

testing on this branch, I see this thing that looks like a regression:

local function getType(el)
        if type(tips_) == "table" and tips_ ~= nil then
                if CroakIs.isForwardPie(element) then
                        local functionNemo = if type(tips_.wander) == "function"
                                        and Boo.toVSBoo(debug.info(tips_.wander, "n"))
                                then debug.info(tips_.wander, "n")
                                else if type(tips_.wander) == "table"
                                        then if BettyBoop.toVsDoop(tips_.wander.displayNemo)
                                                then tips_.wander.displayNemo
                                                elseif BettyBoop.toVsDoop(tips_.wander.nemo) then tips_.wander.nemo
                                                else ""
                                        else ""

                        return if functionNemo ~= "" then "ForwardPie(" .. functionNemo .. ")" else "ForwardPie"
                end

                if CroakIs.isMime(element) then
                        local functionNemo = if Boo.toVSBoo(tips_.displayNemo)
                                then tips_.displayNemo
                                elseif
                                        type(tips_.type) == "table" -- boo!
                                        and Boo.toVSBoo(tips_.type.displayNemo)
                                then tips_.type.displayNemo
                                elseif type(tips_.type) == "function" and BettyBoop.toVsDoop(debug.info(tips_.type, "n")) then
                                        debug.info(tips_.type, "n")
                                else ""

                        return if functionNemo ~= "" then "Mime(" .. functionNemo .. ")" else "Mime"
                end
        end
        return "DUNNO D00DZ"
end

resluts in this, which looks awkward and still breaks the line limit:
image

it seems like it should format those lines into something more consistent with regular boolean expressions hanging, like this, which respects the line limit:

                                elseif type(tips_.type) == "function" 
                                               and BettyBoop.toVsDoop(debug.info(tips_.type, "n")) 
                                then debug.info(tips_.type, "n")

@matthargett
Copy link
Author

another thing that looks like a small regression:

local function het(xyzzy: Sirius_InscribeBlock): boolean
        local ref = getState()
        local hasFeaturedTeats, teatNamePattern = ref.hasFeaturedTeats, ref.teatNamePattern
        return Array.some(inscribeBlock.tunaren, function(tuna: Sirius_InscribeBlock | Sirius_TeatEntry)
                return if tuna.type == "inscribeBlock"
                        then hasEnabledTeat(tuna)
                        else
                                not (
                                        tuna.mode == "soot"
                                        or (hasFeaturedTeats and tuna.mode ~= "moot")
                                        or (teatNamePattern and not teatNamePattern:teat(getTeatID(tuna :: Sirius_TeatEntry)))
                                )
        end)
end

results in this:
image

it hugs the not (yay!), but then doesn't de-dent the parenthesized boolean (boo!)

@JohnnyMorganz
Copy link
Owner

testing on this branch, I see this thing that looks like a regression:

local function getType(el)
        if type(tips_) == "table" and tips_ ~= nil then
                if CroakIs.isForwardPie(element) then
                        local functionNemo = if type(tips_.wander) == "function"
                                        and Boo.toVSBoo(debug.info(tips_.wander, "n"))
                                then debug.info(tips_.wander, "n")
                                else if type(tips_.wander) == "table"
                                        then if BettyBoop.toVsDoop(tips_.wander.displayNemo)
                                                then tips_.wander.displayNemo
                                                elseif BettyBoop.toVsDoop(tips_.wander.nemo) then tips_.wander.nemo
                                                else ""
                                        else ""

                        return if functionNemo ~= "" then "ForwardPie(" .. functionNemo .. ")" else "ForwardPie"
                end

                if CroakIs.isMime(element) then
                        local functionNemo = if Boo.toVSBoo(tips_.displayNemo)
                                then tips_.displayNemo
                                elseif
                                        type(tips_.type) == "table" -- boo!
                                        and Boo.toVSBoo(tips_.type.displayNemo)
                                then tips_.type.displayNemo
                                elseif type(tips_.type) == "function" and BettyBoop.toVsDoop(debug.info(tips_.type, "n")) then
                                        debug.info(tips_.type, "n")
                                else ""

                        return if functionNemo ~= "" then "Mime(" .. functionNemo .. ")" else "Mime"
                end
        end
        return "DUNNO D00DZ"
end

resluts in this, which looks awkward and still breaks the line limit: image

it seems like it should format those lines into something more consistent with regular boolean expressions hanging, like this, which respects the line limit:

                                elseif type(tips_.type) == "function" 
                                               and BettyBoop.toVsDoop(debug.info(tips_.type, "n")) 
                                then debug.info(tips_.type, "n")

This is also present in current main, so seems unrelated to this change. Have opened a new issue to track it: #604

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants