-
Notifications
You must be signed in to change notification settings - Fork 4
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
handle double-indent followed by double-outdent #89
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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