cheshirekow / cmake_format

Source code formatter for cmake listfiles.
GNU General Public License v3.0
964 stars 106 forks source link

Fix `dangle-parens` when line exceeds column limit #224

Open CJKay opened 4 years ago

CJKay commented 4 years ago

NOTE This PR would probably be better served by introducing a dangle-parens-mode to select the precise behaviour, but for now this offers a fix for currently-inconsistent behaviour.


The dangle-parens configuration option is currently ignored when the children of a statement cannot accommodate space for the end parentheses, which can cause undesirable dangling. This occurs particularly frequently in largely indented statements utilising generate expressions, which can often necessarily overflow the column limit:

target_include_directories(
  my-target
  PRIVATE
    $<TARGET_PROPERTY:my-interface,INTERFACE_INCLUDE_DIRECTORIES>)

Which, regardless of the value of dangle-parens, currently becomes:

target_include_directories(
  my-target
  PRIVATE
    $<TARGET_PROPERTY:my-interface,INTERFACE_INCLUDE_DIRECTORIES>
)