handle double-indent followed by double-outdent#89
handle double-indent followed by double-outdent#89fumer-fubotv wants to merge 11 commits intomasterfrom
Conversation
TwitchBronBron
left a comment
There was a problem hiding this comment.
This still isn't working quite right. It's losing indentation. Check out this example:
Here's the code for this example:
namespace tests
class TestStuff
function _()
m.assertEqual(sanitize({
key_0: { env: [], themes: ["any"] }
key_1: { env: ["any"], themes: ["test"] }
key_2: { env: ["prod"], themes: ["test"] }
key_3: { env: ["prod"], themes: ["test"] }
key_4: { env: ["prod", "qa"], themes: ["test", "test"] }
key_5: { env: ["dev", "qa"], themes: ["test"] }
key_6: { env: ["dev", "qa"], themes: ["test", "test"] }
key_7: { env: ["dev", "qa"], themes: ["test"] }
key_8: { env: [], themes: [] }
key_9: { env: ["any"], themes: ["any"], runtimeCheck: function() as boolean
return true
end function }
key_10: { env: ["any"], themes: ["any"], runtimeCheck: function() as boolean
return false
end function }
key_11: { env: ["dev"], themes: ["any"], runtimeCheck: function() as boolean
return true
end function }
key_12: { env: ["any"], themes: ["test"], runtimeCheck: function() as boolean
return true
end function }
}, "prod", "test"), {
enabled: ["key_1", "key_2", "key_4", "key_9"]
available: ["key_0", "key_1", "key_10", "key_11", "key_12", "key_2", "key_3", "key_4", "key_5", "key_6", "key_7", "key_8", "key_9"]
})
end function
end class
end namespace
TwitchBronBron
left a comment
There was a problem hiding this comment.
Here's another edge case I found when running this latest version of the formatter against our codebase. It's double-indenting AA members inside a function call inside an array:
sub createSections(navigationAction as object)
m.sections = [FormatJson({
type: "test"
components: [{
type: "test"
group_id: "1"
}]
slug: "test"
})]
end sub|
However, here's another test that is failing. It's incorrectly adding 1 more indent to the lower end stuff than it should: it.only('formats properly', () => {
expect(formatter.format(undent`
namespace alpha
namespace beta
sub createSections()
m.sections = [
FormatJson({
})]
end sub
end namespace
end namespace
`, { formatMultiLineObjectsAndArrays: false })).to.equal(undent`
namespace alpha
namespace beta
sub createSections()
m.sections = [
FormatJson({
})]
end sub
end namespace
end namespace
`);
}); |
Cannot reproduce while adding this block as a test |
TwitchBronBron
left a comment
There was a problem hiding this comment.
Found another bug. The indent formatter gets out of sync when it encounters empty lines inside an AA. I pushed the failing test and marked it .only().
TwitchBronBron
left a comment
There was a problem hiding this comment.
I found another bug.
it.only('handles unique AA formatting', () => {
formatEqual(undent`
function _()
aa = {
key_12: {
env: ["any"], runtimeCheck: function() as boolean
return true
end function }
}
print "hello"
end function
`, undefined, {
indentStyle: 'tabs',
formatMultiLineObjectsAndArrays: false
});
});



Fixes #85