Skip to content

Comments

Fix unstable formatting around comments in type declarations#435

Merged
JohnnyMorganz merged 10 commits intomasterfrom
type-comments
Apr 8, 2022
Merged

Fix unstable formatting around comments in type declarations#435
JohnnyMorganz merged 10 commits intomasterfrom
type-comments

Conversation

@JohnnyMorganz
Copy link
Owner

Fixes #397 (ref: #430)

@codecov
Copy link

codecov bot commented Apr 2, 2022

Codecov Report

Merging #435 (e996c06) into master (8b3b1dd) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #435   +/-   ##
=======================================
  Coverage   96.42%   96.42%           
=======================================
  Files          14       14           
  Lines        5228     5228           
=======================================
  Hits         5041     5041           
  Misses        187      187           
Impacted Files Coverage Δ
src/formatters/trivia.rs 86.36% <ø> (ø)
src/formatters/trivia_util.rs 94.68% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8b3b1dd...e996c06. Read the comment docs.

@JohnnyMorganz
Copy link
Owner Author

@matthargett @flakolefluk @ktrz thoughts on the new snapshots?

The newly added snapshots of your tests looks good, but I'm not 100% on the change in the table snapshot (its happening because there is a comment in between the equals token and the table in the declaration)

@matthargett
Copy link

innnnnteresting. it would be nice if it didn't force the open brace onto the next line with an indent, but I also think the trade-off here is a good one since the affected regression case is a weird/rare one.

Copy link
Contributor

@ktrz ktrz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the change in this one snapshot is a good tradeoff for having the stable tool output.

@flakolefluk
Copy link

snapshots look good to me! i agree with the previous comments. Let's start with making the output stable. 🎉

@matthargett
Copy link

with this branch, I see an interesting regression where indentation is lost column-width set to 90:

exports.separateDisplayNameAndHOCs =
        function(displayName: string | nil, type_: ElementType): (string | nil, Array<string> | nil)
                if displayName == nil then
                        return nil, nil
                end

                local hocDisplayNames: Array<string>? = nil

                if
                        type_ == ElementTypeClass
                        or type_ == ElementTypeForwardRef
                        or type_ == ElementTypeFunction
                        or type_ == ElementTypeMemo
                then
                        -- ROBLOX deviation: use match instead of indexOf
                        if (displayName :: string):match("%(") then
                                -- ROBLOX deviation: use gmatch instead of /[^()]+/g
                                local matches = (displayName :: string):gmatch("[^()]+")
                                local nextMatch = matches()
                                if nextMatch then
                                        displayName = nextMatch
                                        hocDisplayNames = {}
                                        while (nextMatch :: any) ~= nil do
                                                nextMatch = matches()
                                                table.insert(hocDisplayNames :: Array<string>, nextMatch)
                                        end
                                end
                        end
                end

        end

image

@JohnnyMorganz
Copy link
Owner Author

Turns out the above diff is not related to the PR, but is actually a regression from 0.12.5 -> 0.13.0

@JohnnyMorganz JohnnyMorganz merged commit 602d1a2 into master Apr 8, 2022
@JohnnyMorganz JohnnyMorganz deleted the type-comments branch April 8, 2022 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent formatting when running stylua multiple times

4 participants