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

Avoid adding double-newlines for CRLF #7640

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions crates/uv-workspace/src/pyproject_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,17 +694,18 @@ fn reformat_array_multiline(deps: &mut Array) {
for item in deps.iter_mut() {
let decor = item.decor_mut();
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() {
let decor_prefix = decor
.prefix()
.and_then(|s| s.as_str())
.map(|s| s.split('#').next().unwrap_or("").to_string())
.unwrap_or(String::new())
.trim_start_matches('\n')
.map(|s| s.split('#').next().unwrap_or(""))
.unwrap_or_default()
.trim_start_matches(['\r', '\n'].as_ref())
.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() {
" ".to_string()
} else {
Expand Down
Loading