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

Wrong indentation after multi-line function call #6731

Closed
php4fan opened this issue Nov 20, 2023 · 8 comments · Fixed by #6738
Closed

Wrong indentation after multi-line function call #6731

php4fan opened this issue Nov 20, 2023 · 8 comments · Fixed by #6738
Assignees
Labels
kind:bug Bug report or fix PHP [ci] enable extra PHP tests (php/php.editor)
Milestone

Comments

@php4fan
Copy link

php4fan commented Nov 20, 2023

Apache NetBeans version

Apache NetBeans 19

What happened

After the following code:

<?php

$result = someFunction(
    "example {$postId}"
);

the next line after that should have zero indentation.

Instead, it gets indented with 4 spaces, i.e. one indentation.

A real-world use case might be something like this:

<?php

$result = queryDatabase(
    "SELECT field1, field2, field3, field4, field5 "
        . "FROM table AS t1 "
        . "JOIN table2 AS t2 ON t2.whatever_id = t1.id "
        . "JOIN table2 AS t3 ON t3.whatever_id = t2.id "
        . "WHERE t1.id = {$something['id']}"
);

after which I get even 2 indentations (i.e. 8 spaces).

How to reproduce

In a PHP file type this:

<?php

$result = someFunction(
    "example {$postId}"
);

and then add a newline. Observe how the new line gets automatically indented.

Did this work correctly in an earlier version?

No / Don't know

Operating System

Manjaro Linux

JDK

21; OpenJDK 64-Bit Server VM 21+35

Apache NetBeans packaging

Third-party package

Anything else

No response

Are you willing to submit a pull request?

No

@php4fan php4fan added kind:bug Bug report or fix needs:triage Requires attention from one of the committers labels Nov 20, 2023
@php4fan php4fan changed the title Wrong indentation after function call Wrong indentation after multi-line function call Nov 20, 2023
@junichi11 junichi11 added the PHP [ci] enable extra PHP tests (php/php.editor) label Nov 20, 2023
@junichi11
Copy link
Member

Please write an actual result and an expected result. I'm not sure what you expect yet.

@php4fan
Copy link
Author

php4fan commented Nov 20, 2023

What's unclear about this?:

the next line after that should have zero indentation.
Instead, it gets indented with 4 spaces, i.e. one indentation.

Expected result: there should be no indentation in the next line after the above code.
Observed result: the next line is indented by an apparently random amount.

@junichi11
Copy link
Member

Please write them as code to avoid misunderstanding.

@php4fan
Copy link
Author

php4fan commented Nov 21, 2023

Write what as code? The expected and observed behavior? That makes no sense.

I honestly don't understand what you want from me.
Have you understood what the issue is or not?

I gave you the example code, the instructions to reproduce, the expected and observed behavior. I don't understand what else you need and I don't see what part of the report can possibly be unclear.

Have you tried the example code? You don't notice anything strange?
Maybe it's not reproducing for you? Maybe the fix for 6706 fixed this as well?

@junichi11
Copy link
Member

Please write like this

<?php

$result = someFunction(
    "example {$postId}"
); // type enter key here

Expected result:

<?php

$result = someFunction(
    "example {$postId}"
);
// no indentation here

Actual result:

<?php

$result = someFunction(
    "example {$postId}"
);
    // one indentation is added here

Maybe, what you expect is this, right?
Don't you think it's easier to understand without misunderstanding?

@php4fan
Copy link
Author

php4fan commented Nov 21, 2023

Yes that's what I meant. Can you reproduce?

@junichi11 junichi11 removed the needs:triage Requires attention from one of the committers label Nov 22, 2023
@junichi11
Copy link
Member

Reproducible.

@junichi11 junichi11 self-assigned this Nov 22, 2023
@junichi11 junichi11 added this to the NB21 milestone Nov 22, 2023
junichi11 added a commit to junichi11/netbeans that referenced this issue Nov 22, 2023
- apache#6731
- When a multi-line parameter of a method invocation has a string with a variable(e.g. `"example {$example}"`), ignore the variable within the string(i.e. {$example}) to avoid adding extra indentations
Example:
```php
$x = test(
    "test {$test}"
);// enter key here
```

Before:
```php
$x = test(
    "test {$test}"
);
    // one indentation is added
```

After:
```php
$x = test(
    "test {$test}"
);
// no indentation
```
junichi11 added a commit to junichi11/netbeans that referenced this issue Nov 22, 2023
- apache#6731
- When a multi-line parameter of a method invocation has a string with a variable(e.g. `"example {$example}"`), ignore the variable within the string(i.e. {$example}) to avoid adding extra indentations

Example:
```php
$x = test(
    "test {$test}"
);// enter key here
```

Before:
```php
$x = test(
    "test {$test}"
);
    // one indentation is added
```

After:
```php
$x = test(
    "test {$test}"
);
// no indentation
```
junichi11 added a commit to junichi11/netbeans that referenced this issue Nov 22, 2023
- apache#6731
- When a multi-line parameter of a function/method invocation has a string with a variable(e.g. `"example {$example}"`), ignore the variable within the string(i.e. {$example}) to avoid adding extra indentations

Example:
```php
$x = test(
    "test {$test}"
);// enter key here
```

Before:
```php
$x = test(
    "test {$test}"
);
    // one indentation is added
```

After:
```php
$x = test(
    "test {$test}"
);
// no indentation
```
@junichi11 junichi11 linked a pull request Nov 22, 2023 that will close this issue
junichi11 added a commit that referenced this issue Nov 22, 2023
@junichi11
Copy link
Member

Fixed.

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