google / google/google-java-format

Consistent formatting of multivariable try-with-resource blocks.

Open
#1,392 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
6.2k
Forks
937
Avg merge
6m
Merged PRs (30d)
3

Description

The current formatting of try-with-resource blocks that manage multiple variables is strange, as it results in inconsistent alignment and doesn't match how multiline parameters or code blocks are formatted.

Current output:
```java
try (var input = Files.newInputStream(Path.of("./input"));
var output = Files.newOutputStream(Path.of("./output")); ) {
output.write(input.read());
} catch (IOException _) {
}
```

How I think it should be formatted:
```java
try (
var input = Files.newInputStream(Path.of("./input"));
var output = Files.newOutputStream(Path.of("./output"));
) {
output.write(input.read());
} catch (IOException _) {
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.