palantir / palantir/palantir-java-format

Formatter on/off config disregarded by Palentir IntelliJ's plugin

Open
#1,303 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
907
Forks
101
Avg merge
1d 3h
Merged PRs (30d)
19

Description

IntelliJ's version: 2025.1.1.1 (Ultimate Edition)
Plugin version: 2.67.0

Issue

Given formatter off/on comment is enabled in IntelliJ's configuration (Settings>Editor > Code Style > Formatter tab):

Image

With a code as follow (Spring security config is a good example where we don't want any auto-formatting):

        // @formatter:off
        return http.csrf(CsrfConfigurer::disable)
            .authorizeHttpRequests(authz -> authz.requestMatchers(
                    "/actuator/**", 
                    "/error")
                        .permitAll()
                    .anyRequest().authenticated())
                .sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
            .build();
        // @formatter:on
Expected behaviour

Code between formatter off/on comments should not be formatted by Palentir formatter.

Actual behaviour

Code is formatted by Palentir formatter. But it is properly ignored by IntelliJ's default formatter.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with Palantir Java Format 2.67.0 and IntelliJ IDEA 2025.1.1.1 using the formatter off/on comments shown in the report. Start by locating the formatter's handling of these comments and compare it with IntelliJ's behavior; done means code between the markers remains unchanged while code outside them is formatted.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.