Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Formatting overly long lines does not respect `--lines` range restriction

Open
#1,114 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

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

Research direction

Reproduce the issue with the provided Test.java example and google-java-format --lines 1:1 Test.java, then trace how the --lines range is applied to overly long lines. Done means the command produces no diff when the selected line is already correctly formatted, while formatting remains unchanged outside the requested range.

Written by the indexing model from the issue text.

Description

Let Test.java be:

class Test {
  void foo() {
    // Columns:
    //   1         2         3         4         5         6         7         8         9
    // ..0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
    System.err.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
  }
}

What I did: $ google-java-format --lines 1:1 Test.java | diff Test.java -
What I expected to happen: No diff, since line 1 is already correctly formatted.
What actually happens:

6c6,7
<     System.err.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
---
>     System.err.println(
>         "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
Dominant language
Java
Stars
6.2k
Forks
936
Avg merge
6m
Merged PRs (30d)
3

Getting set up

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.

More from google/google-java-format

All issues in google/google-java-format

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.