Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP - Format adds blank lines each time it is run #7185

Closed
jnmills opened this issue Mar 24, 2024 · 3 comments · Fixed by #7447
Closed

PHP - Format adds blank lines each time it is run #7185

jnmills opened this issue Mar 24, 2024 · 3 comments · Fixed by #7447
Assignees
Labels
kind:bug Bug report or fix PHP [ci] enable extra PHP tests (php/php.editor)
Milestone

Comments

@jnmills
Copy link

jnmills commented Mar 24, 2024

Apache NetBeans version

Apache NetBeans 21

What happened

This is similar/same as legacy report 235228. Does not appear to be in the current NetBeans issues database. If you have an if statement without braces, each time format is run a new blank line is added after the "then" clause.

Language / Project Type / NetBeans Component

PHP code formatting

How to reproduce

Use this code. Note that if you remove " //comment 1" the problem does not occur. When you run (right click)-Format a new line is added before "another comment".

<?php

if (1)
    $y = 0;  // comment 1

    
// another comment

Did this work correctly in an earlier version?

No / Don't know

Operating System

WIndows 10

JDK

11.0.13

Apache NetBeans packaging

Apache NetBeans binary zip

Anything else

Product Version: Apache NetBeans IDE 21
Java: 11.0.13; Java HotSpot(TM) 64-Bit Server VM 11.0.13+10-LTS-370
Runtime: Java(TM) SE Runtime Environment 11.0.13+10-LTS-370
System: Windows 10 version 10.0 running on amd64; Cp1252; en_GB (nb)
User directory: D:\Users\xxx\AppData\Roaming\NetBeans\21
Cache directory: D:\Users\xxx\AppData\Local\NetBeans\Cache\21

Are you willing to submit a pull request?

No

@jnmills jnmills added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Mar 24, 2024
@troizet troizet added the PHP [ci] enable extra PHP tests (php/php.editor) label Mar 25, 2024
@junichi11
Copy link
Member

Please also write an expected result and an actual result. Thanks.

@junichi11
Copy link
Member

OK. Reproducible. Thanks for reporting it.

@junichi11 junichi11 removed the needs:triage Requires attention from one of the committers label Jun 7, 2024
@junichi11
Copy link
Member

@junichi11 junichi11 self-assigned this Jun 7, 2024
@junichi11 junichi11 added this to the NB23 milestone Jun 7, 2024
junichi11 added a commit to junichi11/netbeans that referenced this issue Jun 7, 2024
…acheGH-7185]

- apache#7185
- Don't add the `WHITESPACE_BETWEEN_LINE_COMMENTS` token
- Add unit tests

Example:
```php
if (true)
    $example = 1; // comment1

// comment2
```

Before:
```php
if (true)
    $example = 1; // comment1

new line is added here
// comment2
```

After:
```php
if (true)
    $example = 1; // comment1

// comment2
```
junichi11 added a commit that referenced this issue Jun 9, 2024
…curly-if-with-line-comment

Fix the formatter for no curly "if" statement with a line comment [GH-7185]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Bug report or fix PHP [ci] enable extra PHP tests (php/php.editor)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants