guifier icon indicating copy to clipboard operation
guifier copied to clipboard

Comments in toml gets deleted

Open chickenforday opened this issue 1 month ago • 3 comments

Hello, it seems when you edit the toml in the gui editor it would delete any comments with "#". Im not sure if this is intentional, if so can we have an option not to delete the comments?

Would love to have the guide from comments and ease from the gui editor

chickenforday avatar Nov 24 '25 16:11 chickenforday

hi @chickenforday

this is not intentional but expected. the parsing library used for toml doesnt handle keeping comments. its just deletes comments automatically while parsing. @DecimalTurn created A PR to use his toml library that has the feature of keeping the comments and the style of the toml text while parsing I accpeted the PR but it wasnt used since I changed the whole base code of the guifier library when I changed it I wanted to keep using it but I encountered an error that I couldn't resolve so I just used the smol-toml library actually this is a good opportunity to ask @DecimalTurn about it and whether he can help us. the current base of guifier is using svelte so its so easy to add features and maintain it now. we can for sure use his library

maliknajjar avatar Nov 24 '25 19:11 maliknajjar

Do you remember what was the error with the toml-patch library?

DecimalTurn avatar Nov 25 '25 00:11 DecimalTurn

hi @DecimalTurn I don't really remember what was the error but I remember when I switched between the two libraries the smol-toml was working but toml-patch wasnt. so I just decided to just use to the smol-toml library for now

maliknajjar avatar Nov 25 '25 08:11 maliknajjar

Could it have to do with the fact that the previous state of the TOML string needs to be passed to the patch function?

I'm currently working on a new object-oriented API available inside the toml-patch library. This will allow to just create a tomlDocument object and perform actions on it and it will keep its internal TOML string updated without any other intervention needed.

@maliknajjar Once that new feature is released, would you like me to make a PR to re-introduce comment preservation support?

DecimalTurn avatar Nov 29 '25 23:11 DecimalTurn

Hi @DecimalTurn, that would be awesome! I’d be totally happy with that

maliknajjar avatar Nov 29 '25 23:11 maliknajjar