MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / applyHanging

Function applyHanging

app/src/DataModel/Editors/CodeFormatter.cpp:564–586  ·  view source on GitHub ↗

* @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. */

Source from the content-addressed store, hash-verified

562 * bare "else" re-attaches to the innermost brace-free "if" via the prev-line level.
563 */
564static 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.

Callers 1

scanAllLinesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected