Skip to main content

resolve_alignment

Function resolve_alignment 

Source
pub fn resolve_alignment(
    lines: &[FormatLine],
    alignment: &Alignment,
) -> Alignment
Expand description

Resolve alignment against a document’s full line set into a concrete alignment whose widths are fixed.

This lets individual lines be rendered one at a time while still aligning to the file-wide columns.

The on-disk formatter renders the whole file in one render_lines call, so it never needs this. The LSP, however, emits a separate TextEdit per posting line: it resolves the file-wide widths once with this function, then renders each posting against the returned (width-fixed) alignment so editor output matches rledger format byte-for-byte. For Alignment::CurrencyColumn the column is already absolute, so the alignment is returned unchanged.