-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Literal and folded strings cannot handle "\n \n" at the end of a string #1944
Comments
@kekavc24 I'm not sure this is a new bug caused by dart-lang/yaml_edit#87 but it's something we should fix. At a minimum we should fallback to double quoted string encoded, if nothing else. Indeed, I'd suggest the following steps:
I think (1) is the most important. |
Btw, I can be found on dart_community discord, I'm jonasfj, feel free to ping me. |
Sorry for this. It seems I overwrote it as I was resolving some merge conflicts I encountered while rebasing. I wanted to drop the chomping indicator changes I made in between for dart-lang/yaml_edit#87 so that the squashed commits make sense when merged. I’ll work on it 🫡 |
I have a branch with the changes you suggested, I'll make a PR. @jonasfj Additionally, I also managed to come up with a PoC that solves this issue permanently (hopefully) but comes with some breaking but solvable trade offs in another branch. Issue OneAfter we wrongly tried using The investigation led me back here 😅 , to this very issue we are trying to solve. The chomping indicator was meant to preserve the trailing I investigated If a
No issue, right? Well, that's where the issue is. It means our Okay, issue found. Just apply the additional So I refactored that function to apply line-breaks correctly. After this 2 issues bubbled up:
Issue Two: CommentsOnce this occurred, I backed off to see if this was a known issue that needed fixing. That's when I found #1935. In the issue, YOU outline ways we can/should handle this which ended up being what I had in mind. Thanks! (for the incredible foresight) However, a few issues you overlooked that ended up being the trade-offs I mentioned:
I ended up looking for and skipping comments greedily. At least to have a PoC that works. Armed with this, I continued my investigation started in issue one above. I noticed that both
Dangling line-breaksAt this point, the issues I had were:
I implemented the function that does that and also added some tricks when adding folded/literal strings. It would be nice if you are able to review it and make suggestions for improvements. I can make a draft PR. |
@jonasfj sorry for the extremely long write up. I didn't want to create a PR without outlining the PoC itself since I make so many changes to the existing code without redefining its intention that may need your review. |
Yeah, the PR was getting pretty complicated, we should probably have done fewer things. Also it's not like there weren't any bugs before this PR 🙈 🤣 |
Okay, this might take a while to review. Thinking about it, I do wonder, is it really a good idea to use folded or literal strings without chomping Certainly the Example 1 A: |+
foo
B: true
Example 2 A: |+
foo
I guess what I'm asking is? Instead of trying to handle cases like these correctly, would it be better if we just fallback to use In practice I suspect it's rare that If we have to fallback to double quoted encoding, that's not nearly as bad as throwing a runtime exception because of an internal error, which is what will happen if we modify the YAML document incorrectly ( I'm just asking the question here:
|
True. That's why I still fielded dart-lang/yaml_edit#91 that should precede dart-lang/yaml_edit#90. dart-lang/yaml_edit#90 is just a PoC that I believe can get better once you take a look and help me nitpick the rough edges.
That's why I never attempt to use it at any point within the PoC. I discovered a nifty trick that I strongly highlighted and documented. I was surprised it passes most existing tests including
Yeah, that makes sense |
Adding the test case
'whitespace between line breaks at the end\n \n'
totest/string_test.dart
causes tests to fail.Tests failures:
The text was updated successfully, but these errors were encountered: