mirror of https://github.com/astral-sh/uv
Avoid adding double-newlines for CRLF (#7640)
## Summary Closes https://github.com/astral-sh/uv/issues/7621.
This commit is contained in:
parent
ff066c8ce7
commit
a541d6cf70
|
|
@ -694,17 +694,18 @@ fn reformat_array_multiline(deps: &mut Array) {
|
||||||
for item in deps.iter_mut() {
|
for item in deps.iter_mut() {
|
||||||
let decor = item.decor_mut();
|
let decor = item.decor_mut();
|
||||||
let mut prefix = String::new();
|
let mut prefix = String::new();
|
||||||
// calculating the indentation prefix as the indentation of the first dependency entry
|
|
||||||
|
// Calculate the indentation prefix based on the indentation of the first dependency entry.
|
||||||
if indentation_prefix.is_none() {
|
if indentation_prefix.is_none() {
|
||||||
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("").to_string())
|
.map(|s| s.split('#').next().unwrap_or(""))
|
||||||
.unwrap_or(String::new())
|
.unwrap_or_default()
|
||||||
.trim_start_matches('\n')
|
.trim_start_matches(['\r', '\n'].as_ref())
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
// if there is no indentation then apply a default one
|
// 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 {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue