Fix comment generation when using other kind of linebreaks#46
Merged
liamnichols merged 1 commit intomainCreateAPI/CreateAPI:mainfrom Jul 28, 2022
ln/fix-multiline-commentsCreateAPI/CreateAPI:ln/fix-multiline-commentsCopy head branch name to clipboard
Merged
Fix comment generation when using other kind of linebreaks#46liamnichols merged 1 commit intomainCreateAPI/CreateAPI:mainfrom ln/fix-multiline-commentsCreateAPI/CreateAPI:ln/fix-multiline-commentsCopy head branch name to clipboard
liamnichols merged 1 commit intomainCreateAPI/CreateAPI:mainfrom
ln/fix-multiline-commentsCreateAPI/CreateAPI:ln/fix-multiline-commentsCopy head branch name to clipboard
Conversation
Member
|
I missed the mention. Yes, I just tested it and it looks like it does keep the empty lines. I'm not sure I done it this way originally. The new approach is much better. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
It was reported that when a string that is used in comments uses
\rfor line breaks, the generated code will incorrectly fail to prefix the line with///resulting in non-compiling source files.Fix
From what I could tell, the easiest way to fix this is to separate into components based on anything within the predefined
.newlinesCharacterSet.It was a bit tricky to do this using
firstIndex(of:)in the existing while loop, whereas it was much easier to usecomponents(separatedBy:). However, I am wary because of this comment:However when I compared the implementation, I didn't see a difference in output:
@kean, please could you confirm if I missed anything here? It looks like it works as expected using the updated approach but I might have misunderstood 🙏