Skip to content

Policy formatter drops empty lines in multi-line strings #862

@john-h-kastner-aws

Description

@john-h-kastner-aws

Bug Category

Other

Describe the bug

Given a policy

permit (principal, action, resource)
when { "

a
" };

The formatter drops the new-line character and rewrites the policy to

permit (principal, action, resource)
when { "
a
" };

This is probably because the RcDoc::as_string function cannot be used with strings containing line breaks. Possibly related to #265.

Reproduction steps

[jkastner@dev-dsk-jkastner-1a-3309db3b cedar]$ cargo run format <<<'
permit (principal, action, resource)
when { "

a"};'

permit (principal, action, resource)
when { "
a" };

Metadata

Metadata

Assignees

Labels

bugSomething isn't working. This is as high priority issue.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions