Skip to content
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

test(add): Ensure comments are preserved #10849

Merged
merged 1 commit into from
Jul 13, 2022
Merged

Commits on Jul 13, 2022

  1. test(add): Ensure comments are preserved

    A comment on killercup/cargo-edit#15 had me worried that `cargo add` was
    deleting comments now.  It appears that isn't the case for inline
    tables.
    
    Standard tables however do delete comments.  The work to make sure they
    don't conflicts with another need.  When changing the source, we delete
    the old source fields and append the new which can cause some formatting
    to be carried over unnecessarily.
    
    For example, what would normally look like
    ```toml
    cargo-list-test-fixture-dependency = { optional = true, path = "../dependency", version = "0.0.0" }
    ```
    When fixed to preserve comments with my naive solution looks like
    ```toml
    cargo-list-test-fixture-dependency = { optional = true , path = "../dependency", version = "0.0.0" }
    ```
    Note that `optional = true` used to be last, so space separating it and
    `}` was kept, now separating it and `,`.
    
    More work will be needed to get this into an ideal state but we can at
    least have confidence with inline tables for now.
    epage committed Jul 13, 2022
    Configuration menu
    Copy the full SHA
    b78f918 View commit details
    Browse the repository at this point in the history