cheshirekow / cmake_format

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

line_width causes seemingly inconsistent formatting #318

Open joshmcorreia opened 1 year ago

joshmcorreia commented 1 year ago

Version:

$ cmake-format --version
0.6.13

Config changes:

line_width = 1000

I'm effectively disabling the formatter from altering the line width


Input file:

execute_process(
  COMMAND git rev-parse --abbrev-ref HEAD
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  OUTPUT_VARIABLE GIT_BRANCH
  OUTPUT_STRIP_TRAILING_WHITESPACE)

execute_process(
  COMMAND bash -c "gcc --version | grep ^gcc | sed 's/^.* //g'"
  OUTPUT_VARIABLE toolset)

Expected output: I expect the file to stay the way it is


Actual output:

execute_process(
  COMMAND git rev-parse --abbrev-ref HEAD
  WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  OUTPUT_VARIABLE GIT_BRANCH
  OUTPUT_STRIP_TRAILING_WHITESPACE)

execute_process(COMMAND bash -c "gcc --version | grep ^gcc | sed 's/^.* //g'" OUTPUT_VARIABLE toolset)

Based on the default configuration max_subgroups_hwrap = 2 I don't understand why this last line is getting un-wrapped. Changing the line_width is clearly what's breaking it, but I don't understand why the first line isn't being formatted as well. Any ideas on how to fix this or is this a bug? Thanks!