File tree Expand file tree Collapse file tree 2 files changed +64
-13
lines changed Expand file tree Collapse file tree 2 files changed +64
-13
lines changed Original file line number Diff line number Diff line change @@ -411,21 +411,22 @@ pub(crate) async fn add(
411
411
}
412
412
} ;
413
413
414
- // Keep track of the exact location of the edit.
415
- let index = edit. index ( ) ;
416
-
417
414
// If the edit was inserted before the end of the list, update the existing edits.
418
- for edit in & mut edits {
419
- if * edit. dependency_type == dependency_type {
420
- match & mut edit. edit {
421
- ArrayEdit :: Add ( existing) => {
422
- if * existing >= index {
423
- * existing += 1 ;
415
+ if let ArrayEdit :: Add ( index) = & edit {
416
+ for edit in & mut edits {
417
+ if * edit. dependency_type == dependency_type {
418
+ match & mut edit. edit {
419
+ ArrayEdit :: Add ( existing) => {
420
+ if * existing >= * index {
421
+ println ! ( "Incrementing existing: {:#?}" , existing) ;
422
+ * existing += 1 ;
423
+ }
424
424
}
425
- }
426
- ArrayEdit :: Update ( existing) => {
427
- if * existing >= index {
428
- * existing += 1 ;
425
+ ArrayEdit :: Update ( existing) => {
426
+ if * existing >= * index {
427
+ println ! ( "Incrementing existing: {:#?}" , existing) ;
428
+ * existing += 1 ;
429
+ }
429
430
}
430
431
}
431
432
}
Original file line number Diff line number Diff line change @@ -4539,3 +4539,53 @@ fn custom_dependencies() -> Result<()> {
4539
4539
} ) ;
4540
4540
Ok ( ( ) )
4541
4541
}
4542
+
4543
+ /// Regression test for: <https://github.com/astral-sh/uv/issues/7259>
4544
+ #[ test]
4545
+ fn update_offset ( ) -> Result < ( ) > {
4546
+ let context = TestContext :: new ( "3.12" ) ;
4547
+
4548
+ let pyproject_toml = context. temp_dir . child ( "pyproject.toml" ) ;
4549
+ pyproject_toml. write_str ( indoc ! { r#"
4550
+ [project]
4551
+ name = "project"
4552
+ version = "0.1.0"
4553
+ requires-python = ">=3.12"
4554
+ dependencies = [
4555
+ "iniconfig",
4556
+ ]
4557
+ "# } ) ?;
4558
+
4559
+ uv_snapshot ! ( context. filters( ) , context. add( ) . args( [ "typing-extensions" , "iniconfig" ] ) , @r###"
4560
+ success: true
4561
+ exit_code: 0
4562
+ ----- stdout -----
4563
+
4564
+ ----- stderr -----
4565
+ Resolved 3 packages in [TIME]
4566
+ Prepared 2 packages in [TIME]
4567
+ Installed 2 packages in [TIME]
4568
+ + iniconfig==2.0.0
4569
+ + typing-extensions==4.10.0
4570
+ "### ) ;
4571
+
4572
+ let pyproject_toml = fs_err:: read_to_string ( context. temp_dir . join ( "pyproject.toml" ) ) ?;
4573
+
4574
+ insta:: with_settings!( {
4575
+ filters => context. filters( ) ,
4576
+ } , {
4577
+ assert_snapshot!(
4578
+ pyproject_toml, @r###"
4579
+ [project]
4580
+ name = "project"
4581
+ version = "0.1.0"
4582
+ requires-python = ">=3.12"
4583
+ dependencies = [
4584
+ "iniconfig",
4585
+ "typing-extensions>=4.10.0",
4586
+ ]
4587
+ "###
4588
+ ) ;
4589
+ } ) ;
4590
+ Ok ( ( ) )
4591
+ }
You can’t perform that action at this time.
0 commit comments