Skip to content

Fix de-indent of multi-line call continuation lines ending with a closing paren#147

Merged
chrisdp merged 1 commit into
masterfrom
bugfix/multiline-call-continuation-indent
Jun 30, 2026
Merged

Fix de-indent of multi-line call continuation lines ending with a closing paren#147
chrisdp merged 1 commit into
masterfrom
bugfix/multiline-call-continuation-indent

Conversation

@chrisdp

@chrisdp chrisdp commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #145. Reported via downstream formatting on a real codebase: a multi-line call whose continuation line ends with the closing ) was being de-indented back to the call's level.

m.assertEqual(result, expected,
    `msg`)          ' continuation got pulled back to the m.assertEqual level

Cause

The current line was dedented whenever no indentor preceded the closer on that line (foundIndentorThisLine === false). That condition is also true for a closer at the end of a content/continuation line, so the line got pulled back. It only appeared to work for some lines: e.g. a template interpolation containing parens (${Type(result)}) flips the flag, so the next call's continuation — whose interpolations have no parens (${expected}) — broke instead. The underlying bug affects any multi-line call ending in ), template or not.

Fix

Dedent the current line only when the closer is the first non-whitespace token on the line (a line that actually starts with a closer). This also subsumes the earlier "align a leading }) with its opener" behavior, so the now-redundant foundIndentorThisLine / outdentedThisLine flags are removed.

Added regression tests (both fail on master, pass with the fix). Verified idempotent on playlet, jellyfin-roku, and jellyrock.

…sing paren

A continuation line such as the second line of

    m.assertEqual(result, expected,
        `msg`)

was being pulled back to the call's indent level. The current line was
dedented whenever no indentor preceded the closer on that line, which is also
true for a closer sitting at the *end* of a content/continuation line.

Dedent the current line only when the closer is the first non-whitespace token
on the line (a line that actually starts with a closer). This also covers the
earlier "align a leading `})` with its opener" behavior, so the now-redundant
foundIndentorThisLine / outdentedThisLine flags are removed.
@chrisdp chrisdp merged commit e39086f into master Jun 30, 2026
8 checks passed
@chrisdp chrisdp deleted the bugfix/multiline-call-continuation-indent branch June 30, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants