Repository navigation
Only trim the trailing newline of a %L argument - #2391
Conversation
Egorand
left a comment
There was a problem hiding this comment.
I believe the logic to trim the %S or %P argument was a design decision, with the assumption that in most cases the trailing newline would not be meaningful and hence safe to delete. But I do now think it should probably be on the library user to pre-process the input before passing it to %S/%P, and the library shouldn't be modifying the input.
I do wonder if we should still trim %L arguments, the justification given in the issue description - "%L renders its argument as code text, so trimming layout newlines there is right" - does not explain why it's right. Maybe we should just never trim placeholder args?
|
The Never trimming is the cleaner rule and I would take it. A |
Fixes #2381.
trimTrailingNewLine()andensureEndsWithNewLine()rewrote the lastStringargument of a trailing placeholder. For%L, which renders its argument as code, that is layout; for%Sit is data, soinitializer("%S", "cheese\n")emitted"cheese".Only a
%Largument is rewritten; otherStringarguments are kept and take a requested newline as a format part.TypeSpecTest.multilineStringsreturns to its pre-#1827 expectation; callers relying on the trim see different output.New tests and
multilineStringsfail on main and pass here;./gradlew buildpasses.docs/changelog.mdhas been updated if applicable.be added to the changelog.