-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Format members Array of Cargo.toml in workspace #15084
Comments
Detecting the current style and replicating it, especially as some format styles call for changes based on size, is difficult. As for the example given, I am surprised that there is a leading space that is inserted. We maintain sort order if the array is already sorted. This means we put |
@epage thank you for responding, |
When we
When we sort, that default is no longer relevant. I had thought we had deferred on all formatting decisions until render time. I had forgotten that that code was in there. A quick fix for that leading space is for us to create a |
thanks for opening the issue, |
@epage to fix the leading space we can change the prefix of the first element post the Happy to help 😃 |
What I would recommend is using In implementing this, we generally ask that tests be written and preferably with the test added in its own commit (and passes) and then the follow up commit fixes the behavior and updates the test so it also passes. |
NOTE: the mentioned issue only occurs if the newly added member becomes the first member in the members array, in order to use Solution: we let the Can write-up tests and solution as mentioned once the Issues gets marked as |
No we don't need to know that.
Trying to out-guess the sort like this is tricky |
as value_op is used to
not the guess, we can conditionally check it after the |
Not with |
can you please share, how exactly do you suggest the workaround with it? |
Change from members.push(display_path); to
|
Replacing
which would still have inconsistent format |
There are two formatting issues here:
|
Lack of leading space can only occur when the member from first position moves to next, would it be worth the trouble? |
As I said, we've been punting on detecting formatting styles and making new content consistent with it. |
Problem
While adding new members with
cargo new member_name
in a workspace, the members list should be updated with the new member being added.Current implementation sorts the members list upon adding new member. Prefix of " "(an empty space) gets added before name of each member/display_path resulting in improper formatted output of members list.
Executing mentioned steps should result in Cargo.toml file as below
The members list have inconsistent format.
Correct Format:
Steps
Possible Solution(s)
Format the members list which is Array struct of
toml_edit
lib.I have fixed the issue and have raised the PR.
Notes
No response
Version
The text was updated successfully, but these errors were encountered: