GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Do not hug a lambda on the first line of an if/while/for/switch/try header · Issue #181 · openjavaformat/open-java-format

Do not hug a lambda on the first line of an if/while/for/switch/try header #181

New issue
Copy link
New issue
Copy link
Open
Open
Do not hug a lambda on the first line of an if/while/for/switch/try header#181
Copy link

Description

@abashev
abashev
opened on Nov 1, 2026
Issue body actions

Upstream: google/google-java-format#1507
Kind: idea | Priority: low

google-java-format#1507 (merged 2026-10-29, copybara export) stops hugging block lambdas that start on the first line of a statement header followed by a body (if, while, for, enhanced for, switch, synchronized, try-with-resources). Otherwise the lambda body lands at the same indent as the statement body and the closing })) { hides where the header ends. Expression lambdas break before the parameter instead. Hugging still applies on continuation lines of the header and in do-while conditions. Upstream adds a zero-width HeaderMark to its layout IR for this.

Why it matters: it is the third recent hugging change after google-java-format#1489 and google-java-format#1499, and the only one that targets the if (x.anyMatch(c -> { readability problem. Our palantir-derived engine formats lambdas differently, so the question is whether we have this problem at all.

Affected files in our repo:

  • open-java-format/src/main/java/com/palantir/javaformat/java/JavaInputAstVisitor.java (lambda and argument handling)
  • open-java-format/src/test/resources/com/palantir/javaformat/java/testdata/palantir-chains-lambdas.input and .output

Suggested action: watch / investigate. Run a block lambda inside an if condition through our formatter; adopt only if the body indent equals the statement body indent. Examples: not available - the upstream golden diff was not usable to derive our output.


Filed from an upstream-watch ticket after manual review.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.