-
Notifications
You must be signed in to change notification settings - Fork 39
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
source format removes all comments #15
Comments
Thanks for reporting! This is most probably not an easy thing to fix. The formatter is built on the DumperOptions from SnakeYAML which was not made with editor formatting in mind. I don't have time to look at this at the moment, but I will try to take a look at in a couple of months. |
cool. thanks for looking. |
+1 for this request. At least auto-formatter should be able to act on only selected lines (if no lines are selected, then format all) so I can manually do partial formatting. |
As mentioned this is not an easy fix. The 3rd party parser that is used is not really made with this type of scenario in mind. Suggestions for how this can be implemented or pull-requests are always welcome though. |
+1 |
+1 and I humbly offer my opinion that a comment-nuking formatter is fatally flawed and should be removed from this plugin. |
@chrisinmtown Yeah, you are probably right. |
+1 |
1 similar comment
+1 |
Øystein: @oyse |
SnakeYAML developer. P.S. Please do not use human names when you talk about Open Source project. It is always a community. (SnakeYAML is definitely no one-man-project) |
I wouldn't argue againts calling it 'flawed'. However simply removing it helps no-one and might actually hamper someone. Even a flawed formatter may be useful to someone (i.e. if I don't have comments in my file then its totally fine). So I'd actually argue against removing. If you don't like what the formatter does, you can always simply refrain from using it. If its removed... then all choice regards to using or not using it is removed from the user as well. |
What might be easy to do... is have the formatter run a quick check to see if any comments are present in the file, and if so either:
|
This is not easy. The formatter does not know if there are any comments. They are removed. |
I mean the formatter = "the thing in the YEdit editor which grabs the text from the edit buffer and massages it somehow". Clearly that 'formatter' has access to the text of the document in full and it shouldn't be hard to grep the text with some regexp to see if it contains a comment anywhere. |
@kdvolder Yes, that could be do-able. Good suggestion. |
@Andrei-Pozolotin Adding this to SnakeYAML or to the Yaml 2.0 spec is not easy. I think a better approach would be that someone made a general Yaml formatter that could be used both in YEdit and other places, but I am not aware of any such project unfortunatly. |
+1 for disabling the +1 for leaving the formatter in the current code base. Even though we've disabled the hot key, it's still helpful to have the command available through the QuickAccess toolbar, as a way to convert JSON to more idiomatic YAML. Those JSON sources don't have YAML comments, so the formatter is useful and non-destructive when used that way. +1 for adding text-based comment detection and a pop-up warning before proceeding with formatting. A nice improvement! +1 for (eventually) amending the YAML spec and SnakeYAML implementation to remove the requirement of ignoring/discarding comments. I think that's a significant design flaw that disregards the practical needs of YAML editors, and the humans who use them. My team is slammed right now, but as we have available bandwidth, we hope to contribute to some of the above. |
Source format removes all comments and fixing it is not an easy thing to do. As a temporary measure, we remove the key binding to avoid unexpected information loss for the users.
Can I recommend allowing for an external formatter like the python editor does with pep8? Would give us the option to format things as needed for the particular app. I get that it's not handled in the spec .. but it's heavily used in things like Ansible and others for documenting things in line. |
problem:
Shift+Ctrl+F
removes all commentsorigin:
http://dadacoalition.org/yedit/
system:
The text was updated successfully, but these errors were encountered: