Skip to content

Config option remove_trailing_whitespace_characters_on_save changes semantics of multi-line strings

With the remove_trailing_whitespace_characters_on_save config option enabled, trailing white spaces are removed from every line. If inside of a multi-line string literal, this changes the string literal value and thus the semantics, which is undesired.

In the following example code, the trailing spaces of the first line would be removed:

static const auto literal = R"(
  This is some text with trailing whitespaces:      
  If they get removed, the contents/length of this literal changes!
)";

I sadly know of no easy way to fix this, since any proper solution would most likely require parsing the content in the correct language to determine whether we are inside of a multi-line string literal.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information