Use correct indentation when project table contains open bracket comment (#8387)

## Summary

Now, we use four space (rather than one space) for cases like:

```toml
dependencies = [ # comment 0
    # comment 1
    "anyio==3.7.0", # comment 2
    # comment 3
]
```
This commit is contained in:
Charlie Marsh 2024-10-20 15:56:36 -04:00 committed by GitHub
parent 7e2822d694
commit 6ff674f5bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 9 deletions

View File

@ -893,16 +893,14 @@ fn reformat_array_multiline(deps: &mut Array) {
let decor_prefix = decor
.prefix()
.and_then(|s| s.as_str())
.map(|s| s.split('#').next().unwrap_or(""))
.unwrap_or_default()
.trim_start_matches(['\r', '\n'].as_ref())
.to_string();
.and_then(|s| s.lines().last())
.unwrap_or_default();
// If there is no indentation, use four-space.
indentation_prefix = Some(if decor_prefix.is_empty() {
" ".to_string()
} else {
decor_prefix
decor_prefix.to_string()
});
}