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

Continuation Indentation appears to be doubling the entered value. #7524

Closed
dustinsilva-acquia opened this issue Jun 26, 2024 · 5 comments · Fixed by #7526
Closed

Continuation Indentation appears to be doubling the entered value. #7524

dustinsilva-acquia opened this issue Jun 26, 2024 · 5 comments · Fixed by #7526
Assignees
Labels
kind:bug Bug report or fix PHP [ci] enable extra PHP tests (php/php.editor)
Milestone

Comments

@dustinsilva-acquia
Copy link

dustinsilva-acquia commented Jun 26, 2024

Apache NetBeans version

Apache NetBeans 22

What happened

While attempting PSR12 code conformation, I ran into an issue with the following code doubling "continuation indentation" values. Note that "sprintf" has 8 spaces in-front of it, where it should only have 4. My Continuation Indentation is set to 4, and when trying values like 1,2,3, etc. it is very clearly doubling the indentation amount before sprintf, and its closing paren.

// This is how my formatter makes it look.
// Continuation Indentation = 4.
$output = Utils::runCommand(
        sprintf(
            'value %s %s',
            $prefix,
            $docroot
        ),
        $output
);

// This is how it should look.
$output = Utils::runCommand(
    sprintf(
        'value %s %s',
        $prefix,
        $docroot
    ),
    $output
);

Language / Project Type / NetBeans Component

PHP Project

How to reproduce

create a PHP file, copy in the provided code, set "continuation indentation" to 4, press CTRL+SHIFT+F to format, and notice how many spaces sprintf if from the start of $command_output; if it fails as mine does, the spaces will double the value entered for "continuation indentation".

Did this work correctly in an earlier version?

No / Don't know

Operating System

Mac OS X version 14.5 running on x86_64; UTF-8; en_US (nb)

JDK

Java: 22.0.1; OpenJDK 64-Bit Server VM 22.0.1+8

Apache NetBeans packaging

Third-party package

Anything else

Installed from self contained from Codelerity: https://github.com/codelerity/netbeans-installers/releases/download/v22-build1/Apache-NetBeans-22-x86_64.pkg
Note that this also happens on Apache NetBeans version 15 on the same Mac.
Cannot confirm if this happens on other Operating Systems.

Are you willing to submit a pull request?

No

@dustinsilva-acquia dustinsilva-acquia added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Jun 26, 2024
@junichi11 junichi11 added the PHP [ci] enable extra PHP tests (php/php.editor) label Jun 26, 2024
@junichi11
Copy link
Member

@dustinsilva-acquia
I can't reproduce it.
Please also write an expected result and an actual result.
Please provide an example project with your formatting options if possible.

  1. Create a new project
  2. Write an example code
  3. Project properties > Formatting > Use project specific options
  4. Set your formatting option to reproduce it
  5. Zip your example project
  6. Attach it to this issue

@dustinsilva-acquia
Copy link
Author

sample-project.zip

Thanks for your time on this.

@junichi11
Copy link
Member

Reproducible. Thanks!

Please write your example code like the following to the issue body:

// This is how my formatter makes it look.
// Continuation Indentation = 4.
$output = Utils::runCommand(
        sprintf(
            'value %s %s',
            $prefix,
            $docroot
        ),
        $output
);

// This is how it should look.
$output = Utils::runCommand(
    sprintf(
        'value %s %s',
        $prefix,
        $docroot
    ),
    $output
);

Please use not ` but ``` if your example code has multiple lines.

@junichi11 junichi11 removed the needs:triage Requires attention from one of the committers label Jun 27, 2024
@junichi11 junichi11 self-assigned this Jun 27, 2024
@junichi11 junichi11 added this to the NB23 milestone Jun 27, 2024
junichi11 added a commit to junichi11/netbeans that referenced this issue Jun 27, 2024
- apache#7524
- Don't add an indent token when a static method invocation assigns to a variable
- Add unit tests

Example:
```php
$test = Test::staticMethod(
        test(
            'test',
            $arg1,
            $arg2
        ),
        $arg
);
```

Before:
```php
$test = Test::staticMethod(
        test(
            'test',
            $arg1,
            $arg2
        ),
        $arg
);
```

After:
```php
$test = Test::staticMethod(
    test(
        'test',
        $arg1,
        $arg2
    ),
    $arg
);
```
junichi11 added a commit to junichi11/netbeans that referenced this issue Jun 27, 2024
- apache#7524
- Don't add an indent token when a static method invocation assigns to a variable
- Add unit tests

Example:
```php
// Options: Continuation Indentation = 4
$test = Test::staticMethod(
        test(
            'test',
            $arg1,
            $arg2
        ),
        $arg
);
```

Before:
```php
$test = Test::staticMethod(
        test(
            'test',
            $arg1,
            $arg2
        ),
        $arg
);
```

After:
```php
$test = Test::staticMethod(
    test(
        'test',
        $arg1,
        $arg2
    ),
    $arg
);
```
@junichi11
Copy link
Member

junichi11 added a commit that referenced this issue Jun 29, 2024
…ing-for-static-method-invocation

Fix incorrect formatting for a static method invocation [GH-7524]
@dustinsilva-acquia
Copy link
Author

I did have a few minutes to test this, and it worked in the example I provided, however, when I loaded up a class that had the same code in a method, it would not format it properly--I haven't had time to create a working example, but wanted to share this finding, however brief, in the event it may help you. Thanks for your work on NB!

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.

2 participants