
The old behavior would detect the existence of a `# fmt: on` in a leaf node's comment prefix and immediately mark the node as formatting-on, even if a subsequent `# fmt: off` in the same comment prefix would turn it back off. This change modifies that logic to track the state through the entire prefix and take the final state. Note that this does not fully solve on/off behavior, since any _comment_ lines between the off/on are still formatted. We may need to add virtual leaf nodes to truly solve that. I will leave that for a separate commit/PR. Fixes #1005
36 lines
251 B
Python
36 lines
251 B
Python
# fmt: off
|
|
x = [
|
|
1, 2,
|
|
3, 4,
|
|
]
|
|
# fmt: on
|
|
|
|
# fmt: off
|
|
x = [
|
|
1, 2,
|
|
3, 4,
|
|
]
|
|
# fmt: on
|
|
|
|
x = [
|
|
1, 2, 3, 4
|
|
]
|
|
|
|
# output
|
|
|
|
# fmt: off
|
|
x = [
|
|
1, 2,
|
|
3, 4,
|
|
]
|
|
# fmt: on
|
|
|
|
# fmt: off
|
|
x = [
|
|
1, 2,
|
|
3, 4,
|
|
]
|
|
# fmt: on
|
|
|
|
x = [1, 2, 3, 4]
|