Repository navigation
Commit 493215f
DiffBuilder: fix reindexing of operations involving nested paths (#175)
* create new test files
* fix on_undo logic
When a RemoveOperation or AddOperation is removed, subsequent operations
must have their loactions adjusted whenever they depended on deleted
operation. Previously, the logic only tested self.path == path, which
fails to account for edge cases where self.path.startswith(path) but
self.path != path.
* Added new tests
* removed old test files (tests.py already updated)
* replace startswith with _is_path_prefix
Necessary for the case where prefix == 'a/b' and path == 'a/bc/d' in
which case it should return False, not True.
I also considered using JsonPointer.contains(), but for some reason
JsonPointer('/a/b').contains(JsonPointer('/')) returns False, so it's easier to just compare strings.
* new test to track progress towards proper escape handling
* _is_prefix should take parts, not string paths
Comparing string paths to determine if one path depends on another's
removal is prone to error due to special characters '/' and '~'.
Comparing parts is the correct approach.
* style: variable/method names
* Potential fix for pull request finding 'Make prefix reindexing regression test deterministic'
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: Stefan Kögl <stefan@skoegl.net>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>1 parent d70a4d6 commit 493215f
2 files changed
Lines changed: 134 additions & 45 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
| 202 | + | |
206 | 203 | | |
207 | 204 | | |
208 | 205 | | |
209 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
210 | 216 | | |
211 | 217 | | |
212 | 218 | | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
213 | 225 | | |
214 | 226 | | |
215 | 227 | | |
| |||
228 | 240 | | |
229 | 241 | | |
230 | 242 | | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
235 | 248 | | |
236 | 249 | | |
237 | 250 | | |
238 | 251 | | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
243 | 257 | | |
244 | 258 | | |
245 | 259 | | |
| |||
283 | 297 | | |
284 | 298 | | |
285 | 299 | | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
290 | 305 | | |
291 | 306 | | |
292 | 307 | | |
293 | 308 | | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
298 | 314 | | |
299 | 315 | | |
300 | 316 | | |
| |||
335 | 351 | | |
336 | 352 | | |
337 | 353 | | |
338 | | - | |
| 354 | + | |
339 | 355 | | |
340 | 356 | | |
341 | | - | |
| 357 | + | |
342 | 358 | | |
343 | 359 | | |
344 | 360 | | |
| |||
389 | 405 | | |
390 | 406 | | |
391 | 407 | | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
| 408 | + | |
397 | 409 | | |
398 | 410 | | |
399 | 411 | | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
400 | 422 | | |
401 | | - | |
| 423 | + | |
402 | 424 | | |
403 | 425 | | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
408 | 438 | | |
409 | 439 | | |
410 | | - | |
411 | | - | |
412 | | - | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
413 | 444 | | |
414 | 445 | | |
415 | 446 | | |
416 | 447 | | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
421 | 454 | | |
422 | 455 | | |
423 | | - | |
424 | | - | |
425 | | - | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
426 | 460 | | |
427 | 461 | | |
428 | 462 | | |
| |||
778 | 812 | | |
779 | 813 | | |
780 | 814 | | |
781 | | - | |
| 815 | + | |
782 | 816 | | |
783 | 817 | | |
784 | 818 | | |
| |||
813 | 847 | | |
814 | 848 | | |
815 | 849 | | |
816 | | - | |
| 850 | + | |
817 | 851 | | |
818 | 852 | | |
819 | 853 | | |
| |||
908 | 942 | | |
909 | 943 | | |
910 | 944 | | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
627 | 627 | | |
628 | 628 | | |
629 | 629 | | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
630 | 682 | | |
631 | 683 | | |
632 | 684 | | |
| |||
0 commit comments