pinterest / ktlint

An anti-bikeshedding Kotlin linter with built-in formatter
https://pinterest.github.io/ktlint/
MIT License
6.06k stars 504 forks source link

Fixed [{ }] notation for issue #2675 #2677

Closed Jolanrensen closed 1 month ago

Jolanrensen commented 1 month ago

Fixes https://github.com/pinterest/ktlint/issues/2675

Description

Fixes the erroneous error for notations like [{ }], as described in the issue. The }] case was already handled by https://github.com/pinterest/ktlint/pull/596, but the [{ notation needed some additional fix. There was a special exception for ({, and since this one is similar, I added the case for LBRACKET too.

Two tests were added, one to check that notations like [{ a -> a }], [{ }], and [{}] are allowed, and a second one to check that [ { } ] is formatted correctly.

paul-dingemans commented 1 month ago

Tnx for reporting and fixing. I made some small changes from consistency viewpoint.