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
Duplicated comments of first table in an array of tables #131
Comments
Thank you for telling me the problem! I reproduced it. It is a bug. And the reason is as you pointed out. A quick solution might be to check the first character of the The code for comments was added later than the serializer itself, so it's not very clean... |
Thank you. I Hope you will be able to fix it soon :). |
Although I will further refactor the code related to the comments, but I have added a first aid for this problem. I hope it will resolve the problem. |
@ToruNiina, Fix works only for empty first table. If table is not empty then comment is dublicated inside of the table. input:
output:
|
Thank you for reporting it! On the last saturday I found the core part of the problem reported here (still not fixed yet, though). Essentially, [[test_table]] defines an array that contains tables and a table that is the first element of the array at the same time. A comment on top of [[test_table]] is considered as a comment of both the array and the table element. This is why both the array and the first element has the same comment in your example. Unfortunately, my patch only workarounds the case if [[]] format is selected. Because of the line width limit, your tables are inlined and my (ad-hoc) workaround does not work. In order to fix this problem, we must first clarify whether the comment is for an array or an element. In my opinion, it is okay to consider the comment is for the first element in this case. Then I need to change the value initialization part, but this part is a bit tough and I'm now doing this. Hopefully it will be fixed soon. |
I have just pushed the solution and tests. It seems to be fixed. Thank you again for reporting the problem! |
I got problems with array of tables.
Comments of first table into the array will be duplicated.
Here, in case of an array of tables, each table will serialise its own comments. This is done by on of these lines:
toml11/toml/serializer.hpp
Lines 277 to 285 in c037913
toml11/toml/serializer.hpp
Lines 309 to 317 in c037913
But, after that happened, following lines will duplicate the comment of my first table:
toml11/toml/serializer.hpp
Lines 654 to 662 in c037913
Example:
Inputfile:
Outputfile:
(thanks slarti)
The text was updated successfully, but these errors were encountered: