From c07cdc61619bf2ac873410cbd3fe2701bea33bf3 Mon Sep 17 00:00:00 2001 From: Jo <10510431+j178@users.noreply.github.com> Date: Thu, 3 Oct 2024 20:04:36 +0800 Subject: [PATCH] Remove the first empty line for `uv tree --package foo` (#7885) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary When using `uv tree --package foo`, an extra empty line appears at the beginning, which seems unnecessary since `uv tree` without the package option doesn’t have this. It’s possible that the intention was to add separation between packages, i.e. the correct implementation shoule be: ```rust if !std::mem::take(&mut first) { lines.push(String::new()); } ``` Even if corrected, this extra spacing might be redundant as `uv tree` doesn’t include these empty lines between packages by default. ```console $ uv init project $ cd project $ uv init foo $ uv tree Using CPython 3.12.5 Resolved 2 packages in 1ms foo v0.1.0 project v0.1.0 $ uv tree --package project Using CPython 3.12.5 Resolved 2 packages in 1ms project v0.1.0 ``` --- crates/uv-resolver/src/lock/tree.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/crates/uv-resolver/src/lock/tree.rs b/crates/uv-resolver/src/lock/tree.rs index 703fbf1998a5..f5a3484e8517 100644 --- a/crates/uv-resolver/src/lock/tree.rs +++ b/crates/uv-resolver/src/lock/tree.rs @@ -319,11 +319,7 @@ impl<'env> TreeDisplay<'env> { } } else { let by_package: FxHashMap<_, _> = self.roots.iter().map(|id| (&id.name, id)).collect(); - let mut first = true; for package in &self.packages { - if std::mem::take(&mut first) { - lines.push(String::new()); - } if let Some(id) = by_package.get(package) { path.clear(); lines.extend(self.visit(Node::Root(id), &mut visited, &mut path));