Commit f4a48b5
committed
fix(table): fix _Row.cells can raise IndexError
The original implementation of `_Row.cells` did not take into account
the fact that rows could include unoccupied grid cells at the beginning
and/or end of the row.
This "advanced" feature of tables is sometimes used by the Word table
layout algorithm when the user does not carefully align the right
boundary of cells during resizing, so while quite unusual to be used on
purpose, this arises with some frequency in human-authored documents in
the wild.
The prior implementation of `_Row.cells` assumed that `Table.cells()`
was uniform and the cells for a row could be reliably be computed from
the table column-count and row and column offsets. That assumption
does not always hold and can raise `IndexError` when omitted cells are
present.
This reimplementation remedies that situation. As a side-effect it
should also perform much better when reading large tables.1 parent 512f269 commit f4a48b5
2 files changed
+66
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
106 | 109 | | |
107 | 110 | | |
108 | 111 | | |
| |||
403 | 406 | | |
404 | 407 | | |
405 | 408 | | |
406 | | - | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
407 | 439 | | |
408 | 440 | | |
409 | 441 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
782 | 782 | | |
783 | 783 | | |
784 | 784 | | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
785 | 808 | | |
786 | | - | |
| 809 | + | |
787 | 810 | | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | | - | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
792 | 815 | | |
793 | 816 | | |
794 | 817 | | |
795 | | - | |
796 | | - | |
| 818 | + | |
| 819 | + | |
797 | 820 | | |
798 | 821 | | |
799 | 822 | | |
| |||
821 | 844 | | |
822 | 845 | | |
823 | 846 | | |
824 | | - | |
| 847 | + | |
825 | 848 | | |
826 | 849 | | |
827 | 850 | | |
| |||
0 commit comments