cheshirekow / cmake_format

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

fix: disabling formatting locally breaks code #297

Open JohelEGP opened 2 years ago

JohelEGP commented 2 years ago

Input and expected output:

try_compile( # cmake-format: off
  check "${CMAKE_BINARY_DIR}/JEGPCpp2"
  "_jegp_test.cpp"
  CXX_STANDARD 20
  CXX_STANDARD_REQUIRED YES
  CXX_EXTENSIONS NO) # cmake-format: on

Actual output:

try_compile(
  # cmake-format: off

    )
  check "${CMAKE_BINARY_DIR}/JEGPCpp2"
  "_jegp_test.cpp"
  CXX_STANDARD 20
  CXX_STANDARD_REQUIRED YES
  CXX_EXTENSIONS NO) # cmake-format: on

Configuration:

format:
  line_width: 120
  tab_size: 2
  max_subgroups_hwrap: 3
  max_pargs_hwrap: 6
  max_rows_cmdline: 2
  separate_ctrl_name_with_space: false
  separate_fn_name_with_space: false
  dangle_parens: false
  min_prefix_chars: 8
  max_prefix_chars: 8
  max_lines_hwrap: 2
  line_ending: unix
  command_case: canonical
  keyword_case: unchanged
  always_wrap: []
  enable_sort: true
  autosort: true
  require_valid_layout: false
  layout_passes: {}
markup:
  enable_markup: false

Putting # cmake-format: on at the end of any other line within the balanced parentheses breaks formatting.