Fix unstable formatting around comments in type declarations#435
Fix unstable formatting around comments in type declarations#435JohnnyMorganz merged 10 commits intomasterfrom
Conversation
If there are multiline comments here, it is unlikely we want it singleline
Codecov Report
@@ Coverage Diff @@
## master #435 +/- ##
=======================================
Coverage 96.42% 96.42%
=======================================
Files 14 14
Lines 5228 5228
=======================================
Hits 5041 5041
Misses 187 187
Continue to review full report at Codecov.
|
|
@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) |
|
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. |
ktrz
left a comment
There was a problem hiding this comment.
I think the change in this one snapshot is a good tradeoff for having the stable tool output.
|
snapshots look good to me! i agree with the previous comments. Let's start with making the output stable. 🎉 |
|
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 |
|
Turns out the above diff is not related to the PR, but is actually a regression from 0.12.5 -> 0.13.0 |

Fixes #397 (ref: #430)