Repository navigation
Commit a963fe1
authored
* Preserve inline table key order in item()
`item()` sorted dict-valued keys last in the list/tuple branch even under the
default ``sort_keys=False``, because the sort key kept ``isinstance(i[1],
dict)`` in the tuple unconditionally (unlike the dict branch). For an inline
table this silently reordered keys, e.g.
``item([[{"a": {"x": 1}, "b": 2}]])`` produced ``[[{b = 2, a = {x = 1}}]]``.
Only apply the dicts-last ordering to arrays of tables (which render as
``[[table]]`` headers, where a dict-valued key would otherwise capture the
following keys). Inline tables cannot capture, so their insertion order is now
preserved unless sorting is explicitly requested.
Closes #546
* Sort inline table keys purely alphabetically with sort_keys=True
Inline tables have no capture concern, so there is no reason to force
dict-valued keys last when sorting: dicts-last is a capture-avoidance
mechanism for [[table]] headers, not a sorting preference. Sort inline
table keys purely by key when sort_keys=True.
Addresses review feedback on #552.
---------
Co-authored-by: uttam12331 <[email protected]>
1 parent 446d6fa commit a963fe1
3 files changed
Lines changed: 37 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
394 | 417 | | |
395 | 418 | | |
396 | 419 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
164 | 176 | | |
165 | 177 | | |
166 | 178 | | |
167 | 179 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
| 180 | + | |
172 | 181 | | |
173 | 182 | | |
174 | 183 | | |
| |||
0 commit comments