mirror of https://github.com/astral-sh/uv
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:
parent
7e2822d694
commit
6ff674f5bf
|
|
@ -893,16 +893,14 @@ fn reformat_array_multiline(deps: &mut Array) {
|
||||||
let decor_prefix = decor
|
let decor_prefix = decor
|
||||||
.prefix()
|
.prefix()
|
||||||
.and_then(|s| s.as_str())
|
.and_then(|s| s.as_str())
|
||||||
.map(|s| s.split('#').next().unwrap_or(""))
|
.and_then(|s| s.lines().last())
|
||||||
.unwrap_or_default()
|
.unwrap_or_default();
|
||||||
.trim_start_matches(['\r', '\n'].as_ref())
|
|
||||||
.to_string();
|
|
||||||
|
|
||||||
// If there is no indentation, use four-space.
|
// If there is no indentation, use four-space.
|
||||||
indentation_prefix = Some(if decor_prefix.is_empty() {
|
indentation_prefix = Some(if decor_prefix.is_empty() {
|
||||||
" ".to_string()
|
" ".to_string()
|
||||||
} else {
|
} else {
|
||||||
decor_prefix
|
decor_prefix.to_string()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue