* @brief Returns the hanging-indent level for a line and advances the carried hang state; a * bare "else" re-attaches to the innermost brace-free "if" via the prev-line level. */
| 562 | * bare "else" re-attaches to the innermost brace-free "if" via the prev-line level. |
| 563 | */ |
| 564 | static int applyHanging(const LineInfo& info, HangState& hang) |
| 565 | { |
| 566 | if (info.startsInsideMultiline) { |
| 567 | if (info.hasCode) |
| 568 | hang.pending = 0; |
| 569 | |
| 570 | return 0; |
| 571 | } |
| 572 | |
| 573 | if (!info.hasCode) |
| 574 | return hang.pending; |
| 575 | |
| 576 | if (info.startsWithOpenBrace) |
| 577 | hang.pending = 0; |
| 578 | |
| 579 | int lineHang = hang.pending; |
| 580 | if (info.startsWithElse && hang.pending == 0 && info.outdentLeading == 0 && hang.prevLine > 0) |
| 581 | lineHang = hang.prevLine - 1; |
| 582 | |
| 583 | hang.pending = info.opensHanging ? lineHang + 1 : 0; |
| 584 | hang.prevLine = lineHang; |
| 585 | return lineHang; |
| 586 | } |
| 587 | |
| 588 | /** |
| 589 | * @brief Builds per-line LineInfo and depth-at-start arrays, threading scanner state across lines. |